dsfml.network.sockettcp



class SocketTCP;
SocketTCP wraps a socket using TCP protocol to send data safely (but a bit slower)

this();
Default constructor

bool connect(ushort port, IPAddress hostAddress);
Connect to another computer on a specified port

Params:
ushort port Port to use for transfers (warning : ports < 1024 are reserved)
IPAddress hostAddress IP Address of the host to connect to

Returns:
True if operation has been successful

bool connect(ushort port, char[] IP);
Connect to another computer on a specified port

Params:
ushort port Port to use for transfers (warning : ports < 1024 are reserved)
iP string of the IP Address

Returns:
True if operation has been successful

bool listen(ushort port);
Listen to a specified port for incoming data or connections

Params:
ushort port Port to listen to

Returns:
True if operation has been successful

SocketStatus accept(SocketTCP connected);
Wait for a connection (must be listening to a port). This function is blocking.

Params:
SocketTCP connected Socket containing the connection with the connected client

Returns:
Status code

SocketStatus accept(SocketTCP connected, out IPAddress address);
Wait for a connection (must be listening to a port). This function is blocking.

Params:
SocketTCP connected Socket containing the connection with the connected client
IPAddress address Pointer to an address to fill with client infos

Returns:
Status code

SocketStatus send(byte[] data);
Send an array of bytes to the host (must be connected first)

Params:
byte[] data array of bytes to send

Returns:
Status code

SocketStatus receive(byte[] data, out uint sizeReceived);
Receive an array of bytes from the host (must be connected first). This function will block until a connection was accepted

Params:
byte[] data array to fill (make sure it is big enough)
uint sizeReceived Number of bytes received

Returns:
Status code

Remarks:
Assert if data is null or length == 0



SocketStatus send(Packet packetToSend);
Send a packet of data to the host (must be connected first)

Params:
Packet packetToSend Packet to send

Returns:
Status code



SocketStatus receive(Packet packetToReceive);
Receive a packet from the host (must be connected first). This function will block if the socket is blocking

Params:
Packet packetToReceive Packet to fill with received data

Returns:
Status code



bool isValid();
Check if the socket is in a valid state ; this function can be called any time to check if the socket is OK

Returns:
True if the socket is valid




Page generated by Ddoc.