class TCPSocket

bound server for TCP streams and sessions. More...

Full nameost::TCPSocket
Definition#include <socket.h>
Inheritsost::Socket [protected ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Protected Members


Detailed Description

TCP sockets are used for stream based connected sessions between two sockets. Both error recovery and flow control operate transparently for a TCP socket connection. The TCP socket base class is primary used to bind a TCP "server" for accepting TCP streams.

An implicit and unique TCPSocket object exists in Common C++ to represent a bound TCP socket acting as a "server" for receiving connection requests. This class is not part of TCPStream because such objects normally perform no physical I/O (read or write operations) other than to specify a listen backlog queue and perform "accept" operations for pending connections. The Common C++ TCPSocket offers a Peek method to examine where the next pending connection is coming from, and a Reject method to flush the next request from the queue without having to create a session.

The TCPSocket also supports a "OnAccept" method which can be called when a TCPStream related object is created from a TCPSocket. By creating a TCPStream from a TCPSocket, an accept operation automatically occurs, and the TCPSocket can then still reject the client connection through the return status of it's OnAccept method.

bool  OnAccept (const InetHostAddress &ia, tpport_t port)

OnAccept

[protected virtual]

A method to call in a derived TCPSocket class that is acting as a server when a connection request is being accepted. The server can implement protocol specific rules to exclude the remote socket from being accepted by returning false. The Peek method can also be used for this purpose.

Parameters:
iainternet host address of the client.
portnumber of the client.

Returns: true if client should be accepted.

friend class TCPStream

TCPStream

[protected]

friend class SocketPort

SocketPort

[protected]

friend class tcpstream

tcpstream

[protected]

 TCPSocket (const InetAddress &bind, tpport_t port, int backlog = 5)

TCPSocket

A TCP "server" is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests. If the server cannot be created, an exception is thrown.

Parameters:
bindlocal ip address or interface to use.
portnumber to bind socket under.
backlogsize of connection request queue.

inline InetHostAddress  getRequest (tpport_t *port = NULL)

getRequest

[const]

Return address and port of next connection request. This can be used instead of OnAccept() to pre-evaluate connection requests.

Parameters:
portnumber of requestor.

Returns: host requesting a connection.

void  Reject (void)

Reject

Used to reject the next incoming connection request.

inline InetHostAddress  getLocal (tpport_t *port = NULL)

getLocal

[const]

Used to get local bound address.

Reimplemented from Socket.

inline bool  isPendingConnection (timeout_t timeout = TIMEOUT_INF)

isPendingConnection

Used to wait for pending connection requests.

 ~TCPSocket ()

~TCPSocket

[virtual]

Use base socket handler for ending this socket.