sfSocketTCP Class Reference

#include <SocketTCP.hpp>

List of all members.

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


Detailed Description

sfSocketTCP wraps a socket using TCP protocol to send data safely (but a bit slower)

Definition at line 43 of file SocketTCP.hpp.


Constructor & Destructor Documentation

sfSocketTCP::sfSocketTCP (  ) 

Default constructor

Definition at line 37 of file SocketTCP.cpp.


Member Function Documentation

bool sfSocketTCP::Connect ( unsigned short  Port,
const sfIPAddress HostAddress 
)

Connect to another computer on a specified port

Parameters:
Port : Port to use for transfers (warning : ports < 1024 are reserved)
HostAddress : IP Address of the host to connect to
Returns:
True if operation has been successful

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

Parameters:
Port : Port to listen to
Returns:
True if operation has been successful

Definition at line 81 of file SocketTCP.cpp.

sfSocketTCP sfSocketTCP::Accept ( sfIPAddress Address = NULL  ) 

Wait for a connection (must be listening to a port)

Parameters:
Address : Pointer to an address to fill with client infos (NULL by default)
Returns:
New socket for communicating with connected client

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)

Parameters:
Data : Pointer to the bytes to send
Size : Number of bytes to send
Returns:
True if operation has been successful (false would mean the connection is broken)

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

Parameters:
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
Returns:
True if operation has been successful (false would mean the connection is broken)

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)

Parameters:
Packet : Packet to send
Returns:
True if operation has been successful (false would mean the connection is broken)

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

Parameters:
Packet : Packet to fill with received data
Returns:
True if operation has been successful (false would mean the connection is broken)

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

Returns:
True if operation has been successful

Definition at line 263 of file SocketTCP.cpp.

Referenced by sfServer::Disconnect(), and sfFTP::Disconnect().

bool sfSocketTCP::operator== ( const sfSocketTCP Other  )  const

Comparison operator ==

Parameters:
Other : Socket to compare
Returns:
True if *this == Other

Definition at line 278 of file SocketTCP.cpp.

References mySocket.

bool sfSocketTCP::operator!= ( const sfSocketTCP Other  )  const

Comparison operator !=

Parameters:
Other : Socket to compare
Returns:
True if *this != Other

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...

Parameters:
Other : Socket to compare
Returns:
True if *this < Other

Definition at line 298 of file SocketTCP.cpp.

References mySocket.


The documentation for this class was generated from the following files:
Generated for SFML by  doxygen 1.5.2