sfSocketTCP Class Reference

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

#include <SocketTCP.hpp>

List of all members.


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 >

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.

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

This function is blocking, ie. it won't return before a connection has been accepted

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

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

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

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

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

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

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 240 of file SocketTCP.cpp.

bool sfSocketTCP::Close (  ) 

Close the socket.

Returns:
True if operation has been successful

Definition at line 274 of file SocketTCP.cpp.

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

Comparison operator ==.

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

Definition at line 289 of file SocketTCP.cpp.

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

Comparison operator !=.

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

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

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

Definition at line 309 of file SocketTCP.cpp.


The documentation for this class was generated from the following files: