Network

Functions

Int32 GeIpInitNetwork ()
 
void GeIpCloseNetwork ()
 
IpConnectionGeIpOpenListener (UInt32 ipAddr, Int32 port, BaseThread *thread, Int32 timeout, Bool dontwait, Int32 *ferr)
 
IpConnectionGeIpWaitForIncoming (IpConnection *listener, BaseThread *connection, Int32 *ferr)
 
IpConnectionGeIpOpenOutgoing (const Char *hostname, BaseThread *thread, Int32 initial_timeout, Int32 timeout, Bool dontwait, Int32 *ferr, Int32 retries)
 
void GeIpCloseConnection (IpConnection *&ipc)
 
void GeIpKillConnection (IpConnection *ipc)
 
Int32 GeIpBytesInInputBuffer (IpConnection *ipc)
 
Int GeIpReadBytes (IpConnection *ipc, void *buf, Int size)
 
Int GeIpSendBytes (IpConnection *ipc, void *buf, Int size)
 
void GeIpGetHostAddr (IpConnection *ipc, Char *buf, Int32 bufsize)
 
void GeIpGetRemoteAddr (IpConnection *ipc, Char *buf, Int32 bufsize)
 
void GeRandomSleep (Int32 min, Int32 max)
 
String GetTimeString ()
 
Bool GetMACaddress (UChar *buf, Int32 bufsize)
 

Detailed Description

Function Documentation

◆ GeIpInitNetwork()

Int32 cineware::GeIpInitNetwork ( )

Initializes the network.

Note
Must be called before using the network functions.
Returns
0 if there was an error and 1 for a successful initialization.

◆ GeIpCloseNetwork()

void cineware::GeIpCloseNetwork ( )

Closes the network.

Note
Must be called after using the network functions.

◆ GeIpOpenListener()

IpConnection* cineware::GeIpOpenListener ( UInt32  ipAddr,
Int32  port,
BaseThread thread,
Int32  timeout,
Bool  dontwait,
Int32 ferr 
)

Opens an IP listener.

Parameters
[in]ipAddrThe IP address of the network interface to use for the listener, or 0 to use the default interface.
[in]portThe port of the listener.
[in]threadThe thread to use for the connection. The caller owns the pointed thread.
[in]timeoutThe time after which the listener closes an unresponsive connection.
[in]dontwaitIf true, the TCP/IP flag TCP_NODELAY is set.
Quote from the WinSock documentation:
"The TCP_NODELAY option disables the Nagle algorithm. The Nagle algorithm is used to reduce the number of small packets sent by a host by buffering unacknowledged send data until a full-size packet can be sent.
However, for some applications this algorithm can impede performance, and TCP_NODELAY may be used to turn it off. Application writers should not set TCP_NODELAY unless the impact of doing so is well-understood and desired, since setting TCP_NODELAY can have a significant negative impact of network performance.
TCP_NODELAY is the only supported socket option which uses level IPPROTO_TCP; all other options use level SOL_SOCKET."
[in]ferrThe function error status. Assigned a value different than 0 to indicate failure.
Returns
The IP connection handle for the listener. Must be freed with GeIpCloseConnection(). The caller owns the pointed IpConnection.

◆ GeIpWaitForIncoming()

IpConnection* cineware::GeIpWaitForIncoming ( IpConnection listener,
BaseThread connection,
Int32 ferr 
)

Waits for an incoming connection to listener.

Parameters
[in]listenerThe listener IP connection to wait for. Needs to be freed with GeIpCloseConnection(). The caller owns the pointed IpConnection.
[in]connectionThe thread to use for the connection. The caller owns the pointed thread.
[in]ferrThe function error status. Assigned a value different than 0 to indicate failure.
Returns
The IP connection handle for the waiting connection. Must be freed with GeIpCloseConnection(). The caller owns the pointed IpConnection.

◆ GeIpOpenOutgoing()

IpConnection* cineware::GeIpOpenOutgoing ( const Char hostname,
BaseThread thread,
Int32  initial_timeout,
Int32  timeout,
Bool  dontwait,
Int32 ferr,
Int32  retries 
)

Opens an outgoing IP connection.

Parameters
[in]hostnameThe hostname to connect to. Should include port, e.g. "www.maxon.de:80" or "192.168.0.37:80".
[in]threadThe thread to use for the connection. The caller owns the pointed thread.
[in]initial_timeoutThe timeout for creating the connection.
[in]timeoutThe timeout for the data transfer.
[in]dontwaitIf true, the TCP/IP flag TCP_NODELAY is set.
Quote from the WinSock documentation:
"The TCP_NODELAY option disables the Nagle algorithm. The Nagle algorithm is used to reduce the number of small packets sent by a host by buffering unacknowledged send data until a full-size packet can be sent.
However, for some applications this algorithm can impede performance, and TCP_NODELAY may be used to turn it off. Application writers should not set TCP_NODELAY unless the impact of doing so is well-understood and desired, since setting TCP_NODELAY can have a significant negative impact of network performance.
TCP_NODELAY is the only supported socket option which uses level IPPROTO_TCP; all other options use level SOL_SOCKET."
[in]ferrThe function error status. Assigned a value different than 0 to indicate failure.
[in]retriesDefines how many times the function tries to connect.
Returns
IP connection handle for the outgoing connection. Must be freed with GeIpCloseConnection(). The caller owns the pointed IpConnection.

◆ GeIpCloseConnection()

void cineware::GeIpCloseConnection ( IpConnection *&  ipc)

Closes and frees an IP connection.

Parameters
[in]ipcThe IP connection to close. Assigned nullptr afterwards.

◆ GeIpKillConnection()

void cineware::GeIpKillConnection ( IpConnection ipc)

Kills an IP connection.

Note
This function calls End() for the connection thread.
Parameters
[in]ipcThe IP connection to kill. The caller owns the pointed IpConnection.

◆ GeIpBytesInInputBuffer()

Int32 cineware::GeIpBytesInInputBuffer ( IpConnection ipc)

Checks how many bytes are in the input buffer of a IP connection.

Parameters
[in]ipcThe IP connection to check. The caller owns the pointed IpConnection.
Returns
The number of bytes in the input buffer.

◆ GeIpReadBytes()

Int cineware::GeIpReadBytes ( IpConnection ipc,
void *  buf,
Int  size 
)

Reads bytes from an IP connection.

Parameters
[in]ipcThe IP connection to read from. The caller owns the pointed IpConnection.
[in]bufThe buffer to read to. The caller owns the pointed buffer.
[in]sizeThe size of the buffer.
Returns
The number of bytes read.

◆ GeIpSendBytes()

Int cineware::GeIpSendBytes ( IpConnection ipc,
void *  buf,
Int  size 
)

Sends bytes to a IP connection.

Parameters
[in]ipcThe IP connection to send to. The caller owns the pointed IpConnection.
[in]bufThe buffer to send from. The caller owns the pointed buffer.
[in]sizeThe size of the buffer.
Returns
The number of bytes sent.

◆ GeIpGetHostAddr()

void cineware::GeIpGetHostAddr ( IpConnection ipc,
Char buf,
Int32  bufsize 
)

Gets the host address of a IP connection.

Parameters
[in]ipcThe IP connection. The caller owns the pointed IpConnection.
[in]bufThe buffer to take the host address. The caller owns the pointed buffer.
[in]bufsizeThe size of the buffer.

◆ GeIpGetRemoteAddr()

void cineware::GeIpGetRemoteAddr ( IpConnection ipc,
Char buf,
Int32  bufsize 
)

Gets the remote address of a IP connection.

Parameters
[in]ipcThe IP connection. The caller owns the pointed IpConnection.
[in]bufThe buffer to take the remote address.The caller owns the pointed buffer.
[in]bufsizeThe size of the buffer.

◆ GeRandomSleep()

void cineware::GeRandomSleep ( Int32  min,
Int32  max 
)

Random sleep timer.

Parameters
[in]minThe minimum time in milliseconds.
[in]maxThe maximum time in milliseconds.

◆ GetTimeString()

String cineware::GetTimeString ( )

Unused.

◆ GetMACaddress()

Bool cineware::GetMACaddress ( UChar buf,
Int32  bufsize 
)

Unused.