#include <SFML/Config.h>#include <SFML/Network/IPAddress.h>#include <SFML/Network/SocketStatus.h>#include <SFML/Network/Types.h>Go to the source code of this file.
Functions | |
| CSFML_API sfSocketTCP * | sfSocketTCP_Create () |
| Construct a new TCP socket. | |
| CSFML_API void | sfSocketTCP_Destroy (sfSocketTCP *Socket) |
| Destroy an existing TCP socket. | |
| CSFML_API void | sfSocketTCP_SetBlocking (sfSocketTCP *Socket, sfBool Blocking) |
| Change the blocking state of a TCP socket. | |
| CSFML_API sfSocketStatus | sfSocketTCP_Connect (sfSocketTCP *Socket, unsigned short Port, sfIPAddress HostAddress, float Timeout) |
| Connect a TCP socket to another computer on a specified port. | |
| CSFML_API sfBool | sfSocketTCP_Listen (sfSocketTCP *Socket, unsigned short Port) |
| Listen to a specified port for incoming data or connections. | |
| CSFML_API sfSocketStatus | sfSocketTCP_Accept (sfSocketTCP *Socket, sfSocketTCP **Connected, sfIPAddress *Address) |
| Wait for a connection (must be listening to a port). | |
| CSFML_API sfSocketStatus | sfSocketTCP_Send (sfSocketTCP *Socket, const char *Data, size_t Size) |
| Send an array of bytes to the host (must be connected first). | |
| CSFML_API sfSocketStatus | sfSocketTCP_Receive (sfSocketTCP *Socket, char *Data, size_t MaxSize, size_t *SizeReceived) |
| Receive an array of bytes from the host (must be connected first). | |
| CSFML_API sfSocketStatus | sfSocketTCP_SendPacket (sfSocketTCP *Socket, sfPacket *Packet) |
| Send a packet of data to the host (must be connected first). | |
| CSFML_API sfSocketStatus | sfSocketTCP_ReceivePacket (sfSocketTCP *Socket, sfPacket *Packet) |
| Receive a packet from the host (must be connected first). | |
| CSFML_API sfBool | sfSocketTCP_IsValid (sfSocketTCP *Socket) |
| Check if a socket is in a valid state ; this function can be called any time to check if the socket is OK. | |
| CSFML_API sfSocketStatus sfSocketTCP_Accept | ( | sfSocketTCP * | Socket, | |
| sfSocketTCP ** | Connected, | |||
| sfIPAddress * | Address | |||
| ) |
Wait for a connection (must be listening to a port).
This function is blocking, ie. it won't return before a connection has been accepted
| Socket | : Socket to use for accepting | |
| Connected | : Pointer to a socket pointer that will be filled with the connected client | |
| Address | : Pointer to an address to fill with client infos |
| CSFML_API sfSocketStatus sfSocketTCP_Connect | ( | sfSocketTCP * | Socket, | |
| unsigned short | Port, | |||
| sfIPAddress | HostAddress, | |||
| float | Timeout | |||
| ) |
Connect a TCP socket to another computer on a specified port.
| Socket | : Socket to use for connecting | |
| Port | : Port to use for transfers (warning : ports < 1024 are reserved) | |
| HostAddress | : IP Address of the host to connect to | |
| Timeout | : Maximum time to wait (0 to use no timeout) |
| CSFML_API sfSocketTCP* sfSocketTCP_Create | ( | ) |
Construct a new TCP socket.
| CSFML_API void sfSocketTCP_Destroy | ( | sfSocketTCP * | Socket | ) |
Destroy an existing TCP socket.
| Socket | : Socket to destroy |
| CSFML_API sfBool sfSocketTCP_IsValid | ( | sfSocketTCP * | Socket | ) |
Check if a socket is in a valid state ; this function can be called any time to check if the socket is OK.
| Socket | : Socket to check |
| CSFML_API sfBool sfSocketTCP_Listen | ( | sfSocketTCP * | Socket, | |
| unsigned short | Port | |||
| ) |
Listen to a specified port for incoming data or connections.
| Socket | : Socket to use for listening | |
| Port | : Port to listen to |
| CSFML_API sfSocketStatus sfSocketTCP_Receive | ( | sfSocketTCP * | Socket, | |
| char * | Data, | |||
| size_t | MaxSize, | |||
| size_t * | SizeReceived | |||
| ) |
Receive an array of bytes from the host (must be connected first).
| 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 |
| CSFML_API sfSocketStatus sfSocketTCP_ReceivePacket | ( | sfSocketTCP * | Socket, | |
| sfPacket * | Packet | |||
| ) |
Receive a packet from the host (must be connected first).
| Socket | : Socket to use for receiving | |
| Packet | : Packet to fill with received data |
| CSFML_API sfSocketStatus sfSocketTCP_Send | ( | sfSocketTCP * | Socket, | |
| const char * | Data, | |||
| size_t | Size | |||
| ) |
Send an array of bytes to the host (must be connected first).
| Socket | : Socket to use for sending | |
| Data | : Pointer to the bytes to send | |
| Size | : Number of bytes to send |
| CSFML_API sfSocketStatus sfSocketTCP_SendPacket | ( | sfSocketTCP * | Socket, | |
| sfPacket * | Packet | |||
| ) |
Send a packet of data to the host (must be connected first).
| Socket | : Socket to use for sending | |
| Packet | : Packet to send |
| CSFML_API void sfSocketTCP_SetBlocking | ( | sfSocketTCP * | Socket, | |
| sfBool | Blocking | |||
| ) |
Change the blocking state of a TCP socket.
The default behaviour of a socket is blocking
| Socket | : Socket to modify | |
| Blocking | : Pass sfTrue to set the socket as blocking, or false for non-blocking |