#include <tcpsocket.h>
Inheritance diagram for sockets::TCPSocket:
Public Member Functions | |
TCPSocket (Buffer *rbuf=0, Buffer *wbuf=0) | |
Constructor. | |
TCPSocket (TCPSocket const &tcps) | |
Copy constructor. | |
TCPSocket & | operator= (TCPSocket const &right) |
Assignment operator. | |
virtual bool | connect () |
Connects the socket. | |
virtual bool | connect_next (bool *last=0) |
Connects to the next peer. | |
virtual bool | set_remote (char const *address, char const *port, char const **error=0) |
Same as IPSocket::set_remote(), but resets the next connection to 0 if needed. | |
virtual bool | set_remote (char const *address, unsigned short port, char const **error=0) |
Same as IPSocket::set_remote(), numeric port version. | |
virtual bool | add_remote (char const *address, char const *port, char const **error=0) |
Adds remote address and port. | |
virtual char const * | raddress () const |
Overrides IPSocket::raddress(). | |
virtual unsigned short | rport () const |
Overrides IPSocket::rport(). | |
Protected Member Functions | |
virtual bool | connect (IPInfo const *ipi) |
Connects to the given peer. | |
IPInfo const * | next () const |
Returns the next peer to try to connect to. |
|
Constructor.
|
|
Adds remote address and port to the existing list of peers that this socket can be connected to. It can't be changed once the ssListening, ssConnecting or ssConnected status flags are set on the socket. This function calls the set_remote() function if the ssRemoteInfo status flag is not set. Else it adds the new peers to the TOP of the list.
|
|
Connects the socket to the remote address and port that have been specified through the set_remote() function. This function creates the socket file descriptor if it is not created already, and calls the watch() function to monitor it. The ssCreated and ssMonitored status flags are thus guaranteed to be set if this function succeeds. The socket may not be actually fully connected when this function succeeds; if it is, tne ssConnected and ssWritable status flags are set, the on_connect() function is called, the on_write() function is then called if the ssWritable flag is still set, else the ssConnecting flag is set. In both cases, the watch() function is called to monitor the socket so that incoming events are caught.
|
|
Connects to the next peer. The list of peers is specified through the add_remote() function. This function creates the socket file descriptor if it is not created already, and calls the watch() function to monitor it. The ssCreated and ssMonitored status flags are thus guaranteed to be set if this function succeeds. The socket may not be actually fully connected when this function succeeds; if it is, tne ssConnected and ssWritable status flags are set, the on_connect() function is called, the on_write() function is then called if the ssWritable flag is still set, else the ssConnecting flag is set. In both cases, the watch() function is called to monitor the socket so that incoming events are caught.
|