Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
SocketTCP wraps a socket using TCP protocol to send data safely (but a bit slower). More...
#include <SFML/Network/SocketTCP.hpp>
Public Member Functions | |
| SocketTCP () | |
| Default constructor. | |
| void | SetBlocking (bool Blocking) |
| Change the blocking state of the socket. | |
| Socket::Status | Connect (unsigned short Port, const IPAddress &HostAddress, float Timeout=0.f) |
| Connect to another computer on a specified port. | |
| bool | Listen (unsigned short Port) |
| Listen to a specified port for incoming data or connections. | |
| Socket::Status | Accept (SocketTCP &Connected, IPAddress *Address=NULL) |
| Wait for a connection (must be listening to a port). | |
| Socket::Status | Send (const char *Data, std::size_t Size) |
| Send an array of bytes to the host (must be connected first). | |
| Socket::Status | Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived) |
| Receive an array of bytes from the host (must be connected first). | |
| Socket::Status | Send (Packet &PacketToSend) |
| Send a packet of data to the host (must be connected first). | |
| Socket::Status | Receive (Packet &PacketToReceive) |
| Receive a packet from the host (must be connected first). | |
| bool | Close () |
| Close the socket. | |
| bool | IsValid () const |
| Check if the socket is in a valid state ; this function can be called any time to check if the socket is OK. | |
| bool | operator== (const SocketTCP &Other) const |
| Comparison operator ==. | |
| bool | operator!= (const SocketTCP &Other) const |
| Comparison operator !=. | |
| bool | operator< (const SocketTCP &Other) const |
| Comparison operator <. | |
Friends | |
| class | Selector< SocketTCP > |
SocketTCP wraps a socket using TCP protocol to send data safely (but a bit slower).
Definition at line 45 of file SocketTCP.hpp.
| sf::SocketTCP::SocketTCP | ( | ) |
Default constructor.
| Socket::Status sf::SocketTCP::Accept | ( | SocketTCP & | Connected, |
| IPAddress * | Address = NULL ) |
Wait for a connection (must be listening to a port).
This function will block if the socket is blocking
| Connected | : Socket containing the connection with the connected client |
| Address | : Pointer to an address to fill with client infos (NULL by default) |
| bool sf::SocketTCP::Close | ( | ) |
Close the socket.
| Socket::Status sf::SocketTCP::Connect | ( | unsigned short | Port, |
| const IPAddress & | HostAddress, | ||
| float | Timeout = 0.f ) |
Connect to another computer on a specified port.
| 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, in seconds (0 by default : no timeout) (this parameter is ignored for non-blocking sockets) |
| bool sf::SocketTCP::IsValid | ( | ) | const |
Check if the socket is in a valid state ; this function can be called any time to check if the socket is OK.
| bool sf::SocketTCP::Listen | ( | unsigned short | Port | ) |
Listen to a specified port for incoming data or connections.
| Port | : Port to listen to |
| bool sf::SocketTCP::operator!= | ( | const SocketTCP & | Other | ) | const |
| bool sf::SocketTCP::operator< | ( | const SocketTCP & | Other | ) | const |
Comparison operator <.
Provided for compatibility with standard containers, as comparing two sockets doesn't make much sense...
| Other | : Socket to compare |
| bool sf::SocketTCP::operator== | ( | const SocketTCP & | Other | ) | const |
| Socket::Status sf::SocketTCP::Receive | ( | char * | Data, |
| std::size_t | MaxSize, | ||
| std::size_t & | SizeReceived ) |
Receive an array of bytes from the host (must be connected first).
This function will block if the socket is blocking
| 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 |
| Socket::Status sf::SocketTCP::Receive | ( | Packet & | PacketToReceive | ) |
Receive a packet from the host (must be connected first).
This function will block if the socket is blocking
| PacketToReceive | : Packet to fill with received data |
| Socket::Status sf::SocketTCP::Send | ( | const char * | Data, |
| std::size_t | Size ) |
Send an array of bytes to the host (must be connected first).
| Data | : Pointer to the bytes to send |
| Size | : Number of bytes to send |
| Socket::Status sf::SocketTCP::Send | ( | Packet & | PacketToSend | ) |
Send a packet of data to the host (must be connected first).
| PacketToSend | : Packet to send |
| void sf::SocketTCP::SetBlocking | ( | bool | Blocking | ) |
Change the blocking state of the socket.
The default behaviour of a socket is blocking
| Blocking | : Pass true to set the socket as blocking, or false for non-blocking |
Definition at line 190 of file SocketTCP.hpp.