#include <SocketTCP.hpp>
Public Member Functions | |
sfSocketTCP () | |
bool | Connect (unsigned short Port, const sfIPAddress &HostAddress) |
bool | Listen (unsigned short Port) |
sfSocketTCP | Accept (sfIPAddress *Address=NULL) |
bool | Send (const char *Data, std::size_t Size) |
bool | Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived) |
bool | Send (sfPacket &Packet) |
bool | Receive (sfPacket &Packet) |
bool | Close () |
bool | operator== (const sfSocketTCP &Other) const |
bool | operator!= (const sfSocketTCP &Other) const |
bool | operator< (const sfSocketTCP &Other) const |
Definition at line 43 of file SocketTCP.hpp.
sfSocketTCP::sfSocketTCP | ( | ) |
Default constructor
Definition at line 37 of file SocketTCP.cpp.
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.
References sfIPAddress::ToString().
Referenced by sfFTP::Connect().
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)
Address | : Pointer to an address to fill with client infos (NULL by default) |
Definition at line 117 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 135 of file SocketTCP.cpp.
Referenced by Send(), sfClient::Send(), and sfServer::SendTo().
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 is it big enough) | |
MaxSize | : Maximum number of bytes to read | |
SizeReceived | : Number of bytes received |
Definition at line 172 of file SocketTCP.cpp.
Referenced by Receive().
bool sfSocketTCP::Send | ( | sfPacket & | Packet | ) |
Send a packet of data to the host (must be connected first)
Packet | : Packet to send |
Definition at line 206 of file SocketTCP.cpp.
References sfPacket::GetData(), sfPacket::GetDataSize(), sfPacket::OnSend(), and Send().
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 229 of file SocketTCP.cpp.
References sfPacket::Append(), sfPacket::Clear(), sfPacket::GetDataSize(), sfPacket::OnReceive(), and Receive().
bool sfSocketTCP::Close | ( | ) |
Close the socket
Definition at line 263 of file SocketTCP.cpp.
Referenced by sfServer::Disconnect(), and sfFTP::Disconnect().
bool sfSocketTCP::operator== | ( | const sfSocketTCP & | Other | ) | const |
Comparison operator ==
Other | : Socket to compare |
Definition at line 278 of file SocketTCP.cpp.
References mySocket.
bool sfSocketTCP::operator!= | ( | const sfSocketTCP & | Other | ) | const |
Comparison operator !=
Other | : Socket to compare |
Definition at line 287 of file SocketTCP.cpp.
References mySocket.
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 298 of file SocketTCP.cpp.
References mySocket.