#include <SocketTCP.hpp>
Public Member Functions | |
sfSocketTCP () | |
Default constructor. | |
bool | Connect (unsigned short Port, const sfIPAddress &HostAddress) |
Connect to another computer on a specified port. | |
bool | Listen (unsigned short Port) |
Listen to a specified port for incoming data or connections. | |
sfSocketTCP | Accept (sfIPAddress *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 (sfPacket &Packet) |
Send a packet of data to the host (must be connected first). | |
bool | Receive (sfPacket &Packet) |
Receive a packet from the host (must be connected first). | |
bool | Close () |
Close the socket. | |
bool | operator== (const sfSocketTCP &Other) const |
Comparison operator ==. | |
bool | operator!= (const sfSocketTCP &Other) const |
Comparison operator !=. | |
bool | operator< (const sfSocketTCP &Other) const |
Comparison operator <. | |
Friends | |
class | sfSelector< sfSocketTCP > |
Definition at line 43 of file SocketTCP.hpp.
sfSocketTCP::sfSocketTCP | ( | ) |
bool sfSocketTCP::Connect | ( | unsigned short | Port, | |
const sfIPAddress & | 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 53 of file SocketTCP.cpp.
bool sfSocketTCP::Listen | ( | unsigned short | Port | ) |
Listen to a specified port for incoming data or connections.
Port | : Port to listen to |
Definition at line 81 of file SocketTCP.cpp.
sfSocketTCP sfSocketTCP::Accept | ( | sfIPAddress * | Address = NULL |
) |
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 119 of file SocketTCP.cpp.
bool sfSocketTCP::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 146 of file SocketTCP.cpp.
bool sfSocketTCP::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 183 of file SocketTCP.cpp.
bool sfSocketTCP::Send | ( | sfPacket & | Packet | ) |
Send a packet of data to the host (must be connected first).
Packet | : Packet to send |
Definition at line 217 of file SocketTCP.cpp.
bool sfSocketTCP::Receive | ( | sfPacket & | Packet | ) |
Receive a packet from the host (must be connected first).
This function is blocking, ie. it won't return before a packet is received
Packet | : Packet to fill with received data |
Definition at line 240 of file SocketTCP.cpp.
bool sfSocketTCP::Close | ( | ) |
Close the socket.
Definition at line 274 of file SocketTCP.cpp.
bool sfSocketTCP::operator== | ( | const sfSocketTCP & | Other | ) | const |
Comparison operator ==.
Other | : Socket to compare |
Definition at line 289 of file SocketTCP.cpp.
bool sfSocketTCP::operator!= | ( | const sfSocketTCP & | Other | ) | const |
Comparison operator !=.
Other | : Socket to compare |
Definition at line 298 of file SocketTCP.cpp.
bool sfSocketTCP::operator< | ( | const sfSocketTCP & | 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 309 of file SocketTCP.cpp.