gt2CreateSocket

GameSpy SDK

gt2CreateSocket

Creates a new socket, which can be used for making outgoing connections or accepting incoming connections.

GT2ResultĀ gt2CreateSocket(
GT2Socket * socket,
const char * localAddress,
int outgoingBufferSize,
int incomingBufferSize,
gt2SocketErrorCallback callback );
RoutineRequired HeaderDistribution
gt2CreateSocket<gt2.h>SDKZIP

Return Value

If the function returns GT2Success then the socket was successfully created. Otherwise, GT2 was unable to create the socket.

Parameters

socket
[out] Pointer to the socket handle.
localAddress
[in] The address to bind to locally. Typically of the form ":<port>", e.g., ":7777". Can be NULL or "".
outgoingBufferSize
[in] The byte size of the per-connection buffer for reliable outgoing messages. Can be 0 to use the internal default.
incomingBufferSize
[in] The byte size of the per-connection buffer for out-of-order reliable incoming messages. Can be 0 to use the internal default.
callback
[in] The callback to be called if there is a fatal error with the socket.

Remarks

A socket is an endpoint on the local machine that allows an application to communicate with other applications (through their own sockets) that are typically on remote machines, although they can also be on the local machine (the other application will often be referred to as the "remote machine", even though technically it may be the same machine). A single socket allows an application to both accept connections from remote machines and make connections to remote machines. For most applications, only one socket needs to be created. All incoming connections can be accepted on the socket, and all outgoing connections can be made using the socket. A socket is created with the gt2CreateSocket function. If the function returns GT2Success then the socket was successfully created and bound to the local address (if one was provided). The socket that the "socket" parameter points to is valid until it is closed with gt2CloseSocket, or an error is reported to the gt2SocketErrorCallback callback parameter. It is now ready to be used for making outgoing connections, and can be readied for allowing incoming connections by calling gt2Listen. If the return result is anything other than GT2Success, GT2 was unable to create the socket.