Open Game Engine 2D API
 All Functions Variables
Functions
Network

Functions

int OGE_OpenLocalServer (int iPort)
 Let the local server start to listen on some port.
int OGE_CloseLocalServer ()
 Let the local server stop listening.
int OGE_ConnectServer (string sAddr)
 Connect the server with network address (IP:Port)
int OGE_DisconnectServer (string sAddr)
 Disconnect the server with the network address.
int OGE_DisconnectClient (string sAddr)
 Disconnect the client by network address.
string OGE_GetSocketAddr (int iSockId)
 Get the network address of the socket.
int OGE_GetCurrentSocket ()
 Get current socket.
int OGE_GetUserSocket (int idx)
 Get the user socket by index.
void OGE_SetUserSocket (int iSockId, int idx)
 Set the user socket with index.
int OGE_GetRecvDataSize ()
 Get the size of current receive data.
int OGE_GetRecvDataType ()
 Get the type of current receive data.
char OGE_GetRecvByte (int pos, int &next)
 Read a byte from the receiving buffer.
int OGE_GetRecvInt (int pos, int &next)
 Read an integer from the receiving buffer.
double OGE_GetRecvFloat (int pos, int &next)
 Read a floating-point value from the receiving buffer.
int OGE_GetRecvBuf (int pos, int len, int buf, int &next)
 Copy bytes from the receiving buffer into another buffer.
string OGE_GetRecvStr (int pos, int len, int &next)
 Read a string from the receiving buffer.
int OGE_PutSendingByte (int iSockId, int pos, char value)
 Write a byte into the sending buffer of the socket.
int OGE_PutSendingInt (int iSockId, int pos, int value)
 Write an integer into the sending buffer of the socket.
int OGE_PutSendingFloat (int iSockId, int pos, double value)
 Write a floating-point value into the sending buffer of the socket.
int OGE_PutSendingBuf (int iSockId, int pos, int buf, int len)
 Copy bytes from a buffer into the sending buffer of the socket.
int OGE_PutSendingStr (int iSockId, int pos, string value)
 Write a string into the sending buffer of the socket.
int OGE_SendData (int iSockId, int iDataSize)
 Send the data in the sending buffer of the socket.
string OGE_GetLocalIP ()
 Get local IP address.
int OGE_FindClient (string sAddr)
 Find a client socket by network address.
int OGE_FindServer (string sAddr)
 Find a server socket by network address.
int OGE_GetLocalServer ()
 Get the socket of the local server.

Function Documentation

Let the local server stop listening.

Returns:
Return a non-negative number if succeed
int OGE_ConnectServer ( string  sAddr)

Connect the server with network address (IP:Port)

Parameters:
[in]sAddrThe network address (IP:Port)
Returns:
Returns a client sockect ID
int OGE_DisconnectClient ( string  sAddr)

Disconnect the client by network address.

Parameters:
[in]sAddrThe network address (IP:Port)
Returns:
Return a non-negative number if succeed
int OGE_DisconnectServer ( string  sAddr)

Disconnect the server with the network address.

Parameters:
[in]sAddrThe network address (IP:Port)
Returns:
Return a non-negative number if succeed
int OGE_FindClient ( string  sAddr)

Find a client socket by network address.

Parameters:
[in]sAddrThe network address (IP:Port)
Returns:
The ID of the client socket
int OGE_FindServer ( string  sAddr)

Find a server socket by network address.

Parameters:
[in]sAddrThe network address (IP:Port)
Returns:
The ID of the server sockect

Get current socket.

Returns:
The ID of the socket
string OGE_GetLocalIP ( )

Get local IP address.

Returns:
The IP address

Get the socket of the local server.

Returns:
The ID of the socket
int OGE_GetRecvBuf ( int  pos,
int  len,
int  buf,
int &  next 
)

Copy bytes from the receiving buffer into another buffer.

Parameters:
[in]posCurrent reading position
[in]lenThe count of the bytes
[in]bufThe ID of the target buffer
[out]nextNext reading position
Returns:
The ID of the target buffer
char OGE_GetRecvByte ( int  pos,
int &  next 
)

Read a byte from the receiving buffer.

Parameters:
[in]posCurrent reading position
[out]nextNext reading position
Returns:
The value of the byte

Get the size of current receive data.

Returns:
The size of the receive data

Get the type of current receive data.

Returns:
The data type
double OGE_GetRecvFloat ( int  pos,
int &  next 
)

Read a floating-point value from the receiving buffer.

Parameters:
[in]posCurrent reading position
[out]nextNext reading position
Returns:
The floating-point value
int OGE_GetRecvInt ( int  pos,
int &  next 
)

Read an integer from the receiving buffer.

Parameters:
[in]posCurrent reading position
[out]nextNext reading position
Returns:
The value of the integer
string OGE_GetRecvStr ( int  pos,
int  len,
int &  next 
)

Read a string from the receiving buffer.

Parameters:
[in]posCurrent reading position
[in]lenThe length of the string
[out]nextNext reading position
Returns:
The string
string OGE_GetSocketAddr ( int  iSockId)

Get the network address of the socket.

Parameters:
[in]iSockIdThe ID of the socket
Returns:
The network address (IP:Port)
int OGE_GetUserSocket ( int  idx)

Get the user socket by index.

Parameters:
[in]idxThe index
Returns:
The ID of the socket
int OGE_OpenLocalServer ( int  iPort)

Let the local server start to listen on some port.

Parameters:
[in]iPortThe listening port
Returns:
Return a non-negative number if succeed
int OGE_PutSendingBuf ( int  iSockId,
int  pos,
int  buf,
int  len 
)

Copy bytes from a buffer into the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]posCurrent writing position
[in]bufThe ID of source buffer
[in]lenThe count of the bytes
Returns:
Next writing position
int OGE_PutSendingByte ( int  iSockId,
int  pos,
char  value 
)

Write a byte into the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]posCurrent writing position
[in]valueThe value of the byte
Returns:
Next writing position
int OGE_PutSendingFloat ( int  iSockId,
int  pos,
double  value 
)

Write a floating-point value into the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]posCurrent writing position
[in]valueThe floating-point value
Returns:
Next writing position
int OGE_PutSendingInt ( int  iSockId,
int  pos,
int  value 
)

Write an integer into the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]posCurrent writing position
[in]valueThe value of the integer
Returns:
Next writing position
int OGE_PutSendingStr ( int  iSockId,
int  pos,
string  value 
)

Write a string into the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]posCurrent writing position
[in]valueThe string
Returns:
Next writing position
int OGE_SendData ( int  iSockId,
int  iDataSize 
)

Send the data in the sending buffer of the socket.

Parameters:
[in]iSockIdThe ID of the socket
[in]iDataSizeThe size of the data
Returns:
Return a non-negative number if succeed
void OGE_SetUserSocket ( int  iSockId,
int  idx 
)

Set the user socket with index.

Parameters:
[in]iSockIdThe ID of the socket
[in]idxThe index