SocketUDP.h File Reference

#include <SFML/Config.h>
#include <SFML/Network/IPAddress.h>
#include <SFML/Network/Packet.h>
#include <SFML/Network/SocketStatus.h>

Go to the source code of this file.


Typedefs

typedef sfSocketUDP sfSocketUDP
 sfSocketUDP wraps a socket using UDP protocol to send data fastly (but with less safety)

Functions

CSFML_API sfSocketUDPsfSocketUDP_Create ()
 Construct a new UDP socket.
CSFML_API void sfSocketUDP_Destroy (sfSocketUDP *Socket)
 Destroy an existing UDP socket.
CSFML_API sfBool sfSocketUDP_Bind (sfSocketUDP *Socket, unsigned short Port)
 Bind a socket to a specific port.
CSFML_API sfBool sfSocketUDP_Unbind (sfSocketUDP *Socket)
 Unbind a socket from its previous port, if any.
CSFML_API sfSocketStatus sfSocketUDP_Send (sfSocketUDP *Socket, const char *Data, size_t Size, sfIPAddress Address, unsigned short Port)
 Send an array of bytes.
CSFML_API sfSocketStatus sfSocketUDP_Receive (sfSocketUDP *Socket, char *Data, size_t MaxSize, size_t *SizeReceived, sfIPAddress *Address)
 Receive an array of bytes.
CSFML_API sfSocketStatus sfSocketUDP_SendPacket (sfSocketUDP *Socket, sfPacket *Packet, sfIPAddress Address, unsigned short Port)
 Send a packet of data.
CSFML_API sfSocketStatus sfSocketUDP_ReceivePacket (sfSocketUDP *Socket, sfPacket *Packet, sfIPAddress *Address)
 Receive a packet.
CSFML_API sfBool sfSocketUDP_IsValid (sfSocketUDP *Socket)
 Check if a socket is in a valid state ; this function can be called any time to check if the socket is OK.

Typedef Documentation

typedef struct sfSocketUDP sfSocketUDP

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

Definition at line 41 of file SocketUDP.h.


Function Documentation

CSFML_API sfBool sfSocketUDP_Bind ( sfSocketUDP Socket,
unsigned short  Port 
)

Bind a socket to a specific port.

Parameters:
Socket : Socket to bind
Port : Port to bind the socket to
Returns:
True if operation has been successful

CSFML_API sfSocketUDP* sfSocketUDP_Create (  ) 

Construct a new UDP socket.

Returns:
Pointer to the new socket

CSFML_API void sfSocketUDP_Destroy ( sfSocketUDP Socket  ) 

Destroy an existing UDP socket.

Parameters:
Socket : Socket to destroy

CSFML_API sfBool sfSocketUDP_IsValid ( sfSocketUDP Socket  ) 

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

Parameters:
Socket : Socket to check
Returns:
sfTrue if the socket is valid

CSFML_API sfSocketStatus sfSocketUDP_Receive ( sfSocketUDP Socket,
char *  Data,
size_t  MaxSize,
size_t *  SizeReceived,
sfIPAddress Address 
)

Receive an array of bytes.

This function is blocking, ie. it won't return before some bytes have been received

Parameters:
Socket : Socket to use for receiving
Data : Pointer to a byte array to fill (make sure it is big enough)
MaxSize : Maximum number of bytes to read
SizeReceived : Number of bytes received
Address : Address of the computer which sent the data
Returns:
Socket status

CSFML_API sfSocketStatus sfSocketUDP_ReceivePacket ( sfSocketUDP Socket,
sfPacket Packet,
sfIPAddress Address 
)

Receive a packet.

This function is blocking, ie. it won't return before a packet is received

Parameters:
Socket : Socket to use for receiving
Packet : Packet to fill with received data
Address : Address of the computer which sent the packet
Returns:
Socket status

CSFML_API sfSocketStatus sfSocketUDP_Send ( sfSocketUDP Socket,
const char *  Data,
size_t  Size,
sfIPAddress  Address,
unsigned short  Port 
)

Send an array of bytes.

Parameters:
Socket : Socket to use for sending
Data : Pointer to the bytes to send
Size : Number of bytes to send
Address : Address of the computer to send the packet to
Port : Port to use for communication
Returns:
Socket status

CSFML_API sfSocketStatus sfSocketUDP_SendPacket ( sfSocketUDP Socket,
sfPacket Packet,
sfIPAddress  Address,
unsigned short  Port 
)

Send a packet of data.

Parameters:
Socket : Socket to use for sending
Packet : Packet to send
Address : Address of the computer to send the packet to
Port : Port to use for communication
Returns:
Socket status

CSFML_API sfBool sfSocketUDP_Unbind ( sfSocketUDP Socket  ) 

Unbind a socket from its previous port, if any.

Parameters:
Socket : Socket to unbind
Returns:
sfTrue if operation has been successful