#include <SocketTCP.hpp>
Public Member Functions | |
SocketTCP () | |
Default constructor. | |
bool | Connect (unsigned short Port, const IPAddress &HostAddress) |
Connect to another computer on a specified port. | |
bool | Listen (unsigned short Port) |
Listen to a specified port for incoming data or connections. | |
SocketTCP | Accept (IPAddress *Address=NULL) |
Wait for a connection (must be listening to a port). | |
bool | Send (const char *Data, std::size_t Size) |
Send an array of bytes to the host (must be connected first). | |
bool | Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived) |
Receive an array of bytes from the host (must be connected first). | |
bool | Send (Packet &PacketToSend) |
Send a packet of data to the host (must be connected first). | |
bool | Receive (Packet &PacketToReceive) |
Receive a packet from the host (must be connected first). | |
bool | Close () |
Close the socket. | |
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 > |
Definition at line 46 of file SocketTCP.hpp.
sf::SocketTCP::SocketTCP | ( | ) |
bool sf::SocketTCP::Connect | ( | unsigned short | Port, | |
const IPAddress & | HostAddress | |||
) |
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 |
Definition at line 55 of file SocketTCP.cpp.
bool sf::SocketTCP::Listen | ( | unsigned short | Port | ) |
Listen to a specified port for incoming data or connections.
Port | : Port to listen to |
Definition at line 83 of file SocketTCP.cpp.
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
Address | : Pointer to an address to fill with client infos (NULL by default) |
Definition at line 121 of file SocketTCP.cpp.
bool 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 |
Definition at line 148 of file SocketTCP.cpp.
bool 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 is blocking, ie. it won't return before some bytes have been received
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 |
Definition at line 185 of file SocketTCP.cpp.
bool sf::SocketTCP::Send | ( | Packet & | PacketToSend | ) |
Send a packet of data to the host (must be connected first).
PacketToSend | : Packet to send |
Definition at line 219 of file SocketTCP.cpp.
bool sf::SocketTCP::Receive | ( | Packet & | PacketToReceive | ) |
Receive a packet from the host (must be connected first).
This function is blocking, ie. it won't return before a packet is received
PacketToReceive | : Packet to fill with received data |
Definition at line 242 of file SocketTCP.cpp.
bool sf::SocketTCP::Close | ( | ) |
Close the socket.
Definition at line 276 of file SocketTCP.cpp.
bool sf::SocketTCP::operator== | ( | const SocketTCP & | Other | ) | const |
Comparison operator ==.
Other | : Socket to compare |
Definition at line 291 of file SocketTCP.cpp.
bool sf::SocketTCP::operator!= | ( | const SocketTCP & | Other | ) | const |
Comparison operator !=.
Other | : Socket to compare |
Definition at line 300 of file SocketTCP.cpp.
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 |
Definition at line 311 of file SocketTCP.cpp.