#include <Socket.h>
Inheritance diagram for Socket:
Public Member Functions | |
Socket () | |
virtual | ~Socket () |
virtual void | Open (int fd=0)=0 |
void | Bind (int addr, short port) |
Bind the socket to the specified address and port. | |
void | Connect (int addr, short port) |
TCP: connect to the specified address and port, UDP: accept messages only from the specified source. | |
virtual void | Send (const DCDT_Msg *msg)=0 |
virtual DCDT_Msg * | Receive ()=0 |
void | Close () |
void | ForcedClose () |
void | GetOption (int level, int optname) |
void | SetOption (int level, int optname) |
void | UnSetOption (int level, int optname) |
void | GetName (char *addr, short &port) |
void | GetCommData (int &addr, short &port) |
void | SetLostTimer (int usec) |
void | LostTimerOn () |
void | LostTimerOff () |
void | SetConnTimer (int usec) |
void | ConnTimerOn () |
void | ConnTimerOff () |
void | SetSendTimer (int usec) |
void | SendTimerOn () |
void | SendTimerOff () |
void | UnblockSend () |
void | SetReceiveTimer (int usec) |
void | ReceiveTimerOn () |
void | ReceiveTimerOff () |
void | UnblockReceive () |
int | GetFd () |
Protected Attributes | |
int | sockfd |
int | opened |
= 1 -> socket opened | |
int | bound |
= 1 -> socket bound | |
int | connected |
= 1 -> socket connected | |
int | tconn_flag |
= 1 -> use a timer in accept() | |
int | tlost_flag |
= 1 -> use a timer in communications | |
int | tsend_flag |
= 1 -> use a timer when sending messages | |
int | trecv_flag |
= 1 -> use a timer when receiving messages | |
int | unblock_send_flag |
= 1 -> socket non blocking when sending | |
int | unblock_recv_flag |
= 1 -> socket non blocking when receiving | |
timeval tconn_value tlost_value tsend_value | trecv_value |
int | my_addr |
short | my_port |
A socket is always created in blocking mode.
Ports are stored as short like in the socket API, not as int such as in CommData, out of the library the numeric values are always expressed in network format.
Ex: 192.168.26.250:1500 -> 0xf01aa8c0:0xdc05
Definition at line 44 of file Socket.h.
|
|
|
|
|
Bind the socket to the specified address and port. If port=0 the port to bind to is randomly choose by the kernel, the same for address. Can throw a ChannelError exception if the bind can't be done; on success set bound to 1.
Definition at line 116 of file Socket.h. References bound, DCDT_TRC_COMM, my_addr, my_port, opened, sockfd, and TRC_PRINT. Referenced by DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::Open(), DCDT_Channel_IP::Reopen(), and DCDT_Channel_IP::StaticPrepare(). |
|
Definition at line 163 of file Socket.h. References bound, connected, DCDT_TRC_COMM, opened, sockfd, and TRC_PRINT. Referenced by DCDT_Channel_IP::Close(). |
|
TCP: connect to the specified address and port, UDP: accept messages only from the specified source. If the socket is a tcp one connect to the specified address and port, if it's an udp one receive messages only from the specified address and port. Can throw ConnError exception in case of problems. When the connection is successfully established set connected to 1.
Definition at line 144 of file Socket.h. References connected, DCDT_TRC_COMM, opened, sockfd, and TRC_PRINT. Referenced by DCDT_Channel_IP::StartConn(), and DCDT_Channel_IP::WaitConn(). |
|
Definition at line 284 of file Socket.h. References tconn_flag. Referenced by DCDT_Channel_IP::ConnTimerOff(). |
|
Definition at line 279 of file Socket.h. References tconn_flag. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::ConnTimerOn(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::SetTimers(), and DCDT_Channel_IP::StaticPrepare(). |
|
Definition at line 174 of file Socket.h. References bound, connected, DCDT_TRC_COMM, opened, sockfd, and TRC_PRINT. Referenced by DCDT_Channel_IP::Stop(). |
|
Definition at line 242 of file Socket.h. References sockfd. Referenced by DCDT_Channel_IP::Open(), and DCDT_Channel_IP::Reopen(). |
|
Definition at line 82 of file Socket.h. Referenced by DCDT_Channel_IP::StartConn(), and DCDT_Channel_IP::WaitConn(). |
|
Definition at line 226 of file Socket.h. References sockfd. |
|
Definition at line 186 of file Socket.h. References DCDT_TRC_COMM, sockfd, and TRC_PRINT. Referenced by TCPSocket::SetBufs(), and TCPSocket::SetSegSize(). |
|
Definition at line 268 of file Socket.h. References tlost_flag. Referenced by DCDT_Channel_IP::LostTimerOff(). |
|
Definition at line 263 of file Socket.h. References tlost_flag. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::LostTimerOn(), DCDT_Channel_IP::SetTimers(), and DCDT_Channel_IP::StaticPrepare(). |
|
|
|
|
|
Definition at line 323 of file Socket.h. References trecv_flag. Referenced by DCDT_Channel_IP::ReceiveTimerOff(). |
|
Definition at line 317 of file Socket.h. References trecv_flag, and unblock_recv_flag. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::ReceiveTimerOn(), DCDT_Channel_IP::SetTimers(), and DCDT_Channel_IP::StaticPrepare(). |
|
|
|
Definition at line 301 of file Socket.h. References tsend_flag. Referenced by DCDT_Channel_IP::SendTimerOff(). |
|
Definition at line 295 of file Socket.h. References tsend_flag, and unblock_send_flag. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::SendTimerOn(), and DCDT_Channel_IP::SetTimers(). |
|
Definition at line 273 of file Socket.h. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::SetConnTimer(), DCDT_Channel_IP::SetTimers(), and DCDT_Channel_IP::StaticPrepare(). |
|
Definition at line 257 of file Socket.h. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::SetLostTimer(), DCDT_Channel_IP::SetTimers(), and DCDT_Channel_IP::StaticPrepare(). |
|
Definition at line 200 of file Socket.h. References DCDT_TRC_COMM, sockfd, and TRC_PRINT. |
|
Definition at line 311 of file Socket.h. References trecv_value. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::DynamicPrepare(), DCDT_Channel_IP::SetReceiveTimer(), DCDT_Channel_IP::SetTimers(), DCDT_Channel_IP::StaticPrepare(), and DCDT_Channel_IP::WaitConn(). |
|
Definition at line 289 of file Socket.h. Referenced by TCPSocket::Accept(), DCDT_Channel_IP::SetSendTimer(), and DCDT_Channel_IP::SetTimers(). |
|
Definition at line 328 of file Socket.h. References unblock_recv_flag. Referenced by DCDT_Channel_IP::UnblockReceive(). |
|
Definition at line 306 of file Socket.h. References unblock_send_flag. Referenced by DCDT_Channel_IP::UnblockSend(). |
|
Definition at line 213 of file Socket.h. References DCDT_TRC_COMM, sockfd, and TRC_PRINT. |
|
= 1 -> socket bound
Definition at line 85 of file Socket.h. Referenced by Bind(), Close(), and ForcedClose(). |
|
= 1 -> socket connected
Definition at line 85 of file Socket.h. Referenced by Close(), Connect(), and ForcedClose(). |
|
Definition at line 106 of file Socket.h. Referenced by Bind(). |
|
Definition at line 107 of file Socket.h. Referenced by Bind(). |
|
= 1 -> socket opened
Definition at line 85 of file Socket.h. Referenced by Bind(), Close(), Connect(), and ForcedClose(). |
|
Definition at line 85 of file Socket.h. Referenced by Bind(), Close(), Connect(), ForcedClose(), GetCommData(), GetName(), GetOption(), SetOption(), and UnSetOption(). |
|
= 1 -> use a timer in accept()
Definition at line 85 of file Socket.h. Referenced by ConnTimerOff(), and ConnTimerOn(). |
|
= 1 -> use a timer in communications
Definition at line 85 of file Socket.h. Referenced by LostTimerOff(), and LostTimerOn(). |
|
= 1 -> use a timer when receiving messages
Definition at line 85 of file Socket.h. Referenced by ReceiveTimerOff(), and ReceiveTimerOn(). |
|
Definition at line 105 of file Socket.h. Referenced by SetReceiveTimer(). |
|
= 1 -> use a timer when sending messages
Definition at line 85 of file Socket.h. Referenced by SendTimerOff(), and SendTimerOn(). |
|
= 1 -> socket non blocking when receiving
Definition at line 102 of file Socket.h. Referenced by ReceiveTimerOn(), and UnblockReceive(). |
|
= 1 -> socket non blocking when sending
Definition at line 102 of file Socket.h. Referenced by SendTimerOn(), and UnblockSend(). |