Zusi 3 TCP Protocol Library
An implementation of the Zusi 3 TCP protocol in C++.
Public Member Functions | List of all members
zusi::WinsockBlockingSocket Class Reference

Socket implemented using the built-in Windows Winsock networking functions. More...

#include <WinsockBlockingSocket.h>

Inherits zusi::Socket.

Public Member Functions

 WinsockBlockingSocket (const char *ip_address, int port)
 Construct a new socket and initiate a TCP connection. More...
 
virtual int ReadBytes (void *dest, int bytes)
 Try to read bytes into dest from socket. More...
 
virtual int WriteBytes (const void *src, int bytes)
 Try to write bytes from src to socket. More...
 

Detailed Description

Socket implemented using the built-in Windows Winsock networking functions.

If using this class, link in ws2_32.lib.

Constructor & Destructor Documentation

zusi::WinsockBlockingSocket::WinsockBlockingSocket ( const char *  ip_address,
int  port 
)

Construct a new socket and initiate a TCP connection.

Parameters
ip_addressNull-terminated string of IP Address to connect to
portPort to connection to, usually 1436.
Exceptions
std::runtime_errorsystem error when creating socket

Member Function Documentation

int zusi::WinsockBlockingSocket::ReadBytes ( void *  dest,
int  bytes 
)
virtual

Try to read bytes into dest from socket.

Method should block until all requested bytes are read, or the stream ends

Parameters
destData buffer to write to
bytesNumber of bytes to read
Returns
Number of bytes read

Implements zusi::Socket.

int zusi::WinsockBlockingSocket::WriteBytes ( const void *  src,
int  bytes 
)
virtual

Try to write bytes from src to socket.

Parameters
srcData buffer to read from
bytesNumber of bytes to read
Returns
Number of bytes successfully written

Implements zusi::Socket.


The documentation for this class was generated from the following files: