dsfml.network.socketudp



class SocketUDP;
SocketUDP wraps a socket using UDP protocol to send data fastly (but with less safety)

this();
Default constructor

bool bind(ushort port);
Bind the socket to a specific port

Params:
ushort port Port to bind the socket to

Returns:
True if operation has been successful



bool unbind();
Unbind the socket from its previous port, if any

Returns:
True if operation has been successful



SocketStatus send(byte[] data, IPAddress address, ushort port);
Send an array of bytes

Params:
byte[] data bytes array to send
IPAddress address Address of the computer to send the packet to
ushort port Port to send the data to

Returns:
Status code



SocketStatus receive(byte[] data, out uint sizeReceived, IPAddress address);
Receive an array of bytes. This function is blocking.

Params:
byte[] data Pointer to a byte array to fill (make sure it is big enough)
uint sizeReceived Number of bytes received
IPAddress address Address of the computer which sent the data

Returns:
Status code

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



SocketStatus send(Packet packetToSend, IPAddress address, ushort port);
Send a packet of data

Params:
Packet packetToSend Packet to send
IPAddress address Address of the computer to send the packet to
ushort port Port to send the data to

Returns:
Status code



SocketStatus receive(Packet packetToReceive, out IPAddress address);
Receive a packet. This function is blocking.

Params:
Packet packetToReceive Packet to fill with received data
IPAddress address Address of the computer which sent the packet

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



ushort getPort();
Get the port the socket is currently bound to

Returns:
Current port (0 means the socket is not bound)


Page generated by Ddoc.