#include <SocketUN.hh>
Public Member Functions | |
SocketUN (SignalHandlerType theType=stSignalInterrupt) | |
Does not open the socket, see Init methods. | |
~SocketUN () | |
Close the socket. | |
int | connectUN (pid_t Server_pid) |
Called by client to connect. | |
void | acceptUN (int RTIA_port) |
Called by server to open the socket and wait for the connection. | |
bool | isDataReady () |
int | returnSocket () |
void | send (const unsigned char *, size_t) throw (NetworkError, NetworkSignal) |
send Message using Socket UNIX. | |
void | receive (const unsigned char *, size_t) throw (NetworkError, NetworkSignal) |
Protected Member Functions | |
void | error (const char *) throw (NetworkError) |
error. | |
Protected Attributes | |
int | _socket_un |
bool | _est_serveur |
bool | _est_init_un |
SignalHandlerType | HandlerType |
std::string | name |
Private Attributes | |
Socket::ByteCount_t | SentBytesCount |
Socket::ByteCount_t | RcvdBytesCount |
int | sock_connect |
pdCDebug * | pD |
On windows platform this socket class is implemented using a TCP socket since Unix socket are not available. IMPORTANT NOTE: This UNIX socket implementation uses a Read Buffer to improve global read performances(by reducing Read system calls). An important drawback of this improvement is that a socket can be marked as empty for the system, but in fact there is data waiting in the read buffer. This is especially a problem for processes using the 'select' system call: the socket won't be marked as ready for reading, because all data has already been read, and is waiting in the internal buffer. Therefore, before returning to a select loop, be sure to call the IsDataReady method to check whether any data is waiting for processing.
Definition at line 62 of file SocketUN.hh.
SocketUN | ( | SignalHandlerType | theType = stSignalInterrupt |
) |
Does not open the socket, see Init methods.
Definition at line 252 of file SocketUN.cc.
References PrettyDebug::Out(), SocketUN::pD, and pdInit.
~SocketUN | ( | ) |
Close the socket.
Definition at line 270 of file SocketUN.cc.
References SocketUN::_est_init_un, SocketUN::_est_serveur, SocketUN::_socket_un, SocketUN::name, PrettyDebug::Out(), SocketUN::pD, pdCom, pdTerm, SocketUN::RcvdBytesCount, SocketUN::SentBytesCount, and SocketUN::sock_connect.
int connectUN | ( | pid_t | Server_pid | ) |
Called by client to connect.
Definition at line 164 of file SocketUN.cc.
References MAX_ATTEMPTS, NOM_FICHIER_SOCKET, pdError, and pdInit.
Referenced by RTI::RTIambassador::RTIambassador().
void acceptUN | ( | int | RTIA_port | ) |
Called by server to open the socket and wait for the connection.
Definition at line 55 of file SocketUN.cc.
References SocketUN::_est_init_un, SocketUN::_est_serveur, SocketUN::_socket_un, SocketUN::error(), SocketUN::name, NOM_FICHIER_SOCKET, PrettyDebug::Out(), SocketUN::pD, pdError, pdInit, and SocketUN::sock_connect.
Referenced by Communications::Communications().
bool isDataReady | ( | ) |
Indicates whether any data as already been read from the system socket and is waiting in the internal buffer
Definition at line 381 of file SocketUN.cc.
Referenced by Communications::readMessage().
int returnSocket | ( | ) |
Definition at line 396 of file SocketUN.cc.
References SocketUN::_socket_un.
Referenced by Communications::readMessage().
void send | ( | const unsigned char * | buffer, | |
size_t | size | |||
) | throw (NetworkError, NetworkSignal) |
send Message using Socket UNIX.
buffer | buffer to send | |
size | buffer size |
Definition at line 307 of file SocketUN.cc.
References SocketUN::_est_init_un, SocketUN::_socket_un, SocketUN::HandlerType, PrettyDebug::Out(), SocketUN::pD, pdExcept, pdTrace, SocketUN::SentBytesCount, and certi::stSignalInterrupt.
void receive | ( | const unsigned char * | buffer, | |
size_t | Size | |||
) | throw (NetworkError, NetworkSignal) |
Definition at line 403 of file SocketUN.cc.
References SocketUN::_est_init_un, SocketUN::_socket_un, SocketUN::HandlerType, PrettyDebug::Out(), SocketUN::pD, pdExcept, pdTrace, SocketUN::RcvdBytesCount, and certi::stSignalInterrupt.
void error | ( | const char * | msg | ) | throw (NetworkError) [protected] |
int _socket_un [protected] |
Definition at line 92 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), SocketUN::receive(), SocketUN::returnSocket(), SocketUN::send(), and SocketUN::~SocketUN().
bool _est_serveur [protected] |
Definition at line 95 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), and SocketUN::~SocketUN().
bool _est_init_un [protected] |
Definition at line 96 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), SocketUN::receive(), SocketUN::send(), and SocketUN::~SocketUN().
SignalHandlerType HandlerType [protected] |
std::string name [protected] |
Definition at line 100 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), and SocketUN::~SocketUN().
Socket::ByteCount_t SentBytesCount [private] |
Definition at line 104 of file SocketUN.hh.
Referenced by SocketUN::send(), and SocketUN::~SocketUN().
Socket::ByteCount_t RcvdBytesCount [private] |
Definition at line 105 of file SocketUN.hh.
Referenced by SocketUN::receive(), and SocketUN::~SocketUN().
int sock_connect [private] |
Definition at line 108 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), and SocketUN::~SocketUN().
Definition at line 110 of file SocketUN.hh.
Referenced by SocketUN::acceptUN(), SocketUN::receive(), SocketUN::send(), SocketUN::SocketUN(), and SocketUN::~SocketUN().