LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
|
TCP/IP connection socket class. More...
#include <tcp_socket.h>
Public Member Functions | |
TCPSocket (const char *hostname, const int port) | |
constructor for client socket More... | |
~TCPSocket () | |
destructor. close socket automatically | |
int | connect () |
make connection More... | |
int | writeToStream (const char *data, const std::size_t len) |
send stream data to the connected host. More... | |
int | readFromStream (char *buf, const std::size_t len) |
receive stream data from the connected remote host. More... | |
![]() | |
virtual | ~AbstractSocket () |
destructor. close socket automatically | |
int | fd () const |
returns socket file descriptor More... | |
bool | isOpen () const |
check if socket is opened or not. More... | |
int | close () |
close socket More... | |
const HostAddress & | localAddress () const |
get the local address object More... | |
HostAddress::PortNumber | localPort () const |
get the port number of destination address More... | |
const HostAddress & | peerAddress () const |
get the peer address object More... | |
std::string | peerName () const |
get the host name of destination address More... | |
HostAddress::PortNumber | peerPort () const |
get the port number of destination address More... | |
Additional Inherited Members | |
![]() | |
enum | SocketType { DATAGRAM_TYPE , STREAM_TYPE , UNKNOWN_TYPE } |
socket type definition | |
![]() | |
AbstractSocket () | |
protected constructor to prevent instantiation | |
bool | open (const SocketType type) |
open socket More... | |
bool | bind (const HostAddress::PortNumber port) |
bind the socket to local address More... | |
bool | setPeerAddress (const char *hostname, const HostAddress::PortNumber port) |
set the address info of the specified remote host. More... | |
int | setNonBlocking () |
set non blocking mode. More... | |
int | connectToPresetAddr () |
connect to address set by setAddr() More... | |
![]() | |
HostAddress | M_local_address |
local address | |
HostAddress | M_peer_address |
destination address | |
TCP/IP connection socket class.
rcsc::TCPSocket::TCPSocket | ( | const char * | hostname, |
const int | port | ||
) |
constructor for client socket
hostname | remote host name (or IP address) |
port | port number to send packet |
int rcsc::TCPSocket::connect | ( | ) |
make connection
int rcsc::TCPSocket::readFromStream | ( | char * | buf, |
const std::size_t | len | ||
) |
receive stream data from the connected remote host.
buf | buffer to receive data |
len | maximal length of buffer buf |
0 | error occured and errno is EWOULDBLOCK |
-1 | error occured |
int rcsc::TCPSocket::writeToStream | ( | const char * | data, |
const std::size_t | len | ||
) |
send stream data to the connected host.
data | the pointer to the data to be sent. |
len | the length of data. |