LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
|
UDP/IP connection socket class. More...
#include <udp_socket.h>
Public Member Functions | |
UDPSocket (const int port) | |
constructor for server socket More... | |
UDPSocket (const char *hostname, const int port) | |
constructor for client socket More... | |
~UDPSocket () | |
destructor. close socket automatically | |
int | writeDatagram (const char *data, const size_t len) |
send datagram packet to the connected host. More... | |
int | writeDatagram (const char *data, const size_t len, const HostAddress &dest) |
send datagram packet to the specified host. More... | |
int | readDatagram (char *buf, const size_t len) |
receive datagram packet from the connected remote host. More... | |
int | readDatagram (char *buf, const size_t len, HostAddress *from) |
receive datagram packet 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 | |
UDP/IP connection socket class.
|
explicit |
constructor for server socket
port | port number to receive packet. |
rcsc::UDPSocket::UDPSocket | ( | 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::UDPSocket::readDatagram | ( | char * | buf, |
const size_t | len | ||
) |
receive datagram packet from the connected remote host.
buf | buffer to receive data |
len | maximum length of the buffer array |
0 | error occured and errno is EWOULDBLOCK |
-1 | error occured |
int rcsc::UDPSocket::readDatagram | ( | char * | buf, |
const size_t | len, | ||
HostAddress * | from | ||
) |
receive datagram packet from the connected remote host.
buf | buffer to receive data |
len | maximum length of the buffer array |
addr | the source host address is set to this variable |
0 | error occured and errno is EWOULDBLOCK |
-1 | error occured |
int rcsc::UDPSocket::writeDatagram | ( | const char * | data, |
const size_t | len | ||
) |
send datagram packet to the connected host.
data | the pointer to the data to be sent. |
len | the length of data. |
int rcsc::UDPSocket::writeDatagram | ( | const char * | data, |
const size_t | len, | ||
const HostAddress & | dest | ||
) |
send datagram packet to the specified host.
data | the pointer to the data to be sent. |
len | the length of data. |
dest | the target host address |