1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
.TH "TCPSocket" 3 "19 Jul 2003" "CommonC++" \" -*- nroff -*-
.ad l
.nh
.SH NAME
TCPSocket \- TCP sockets are used for stream based connected sessions between two sockets. bound server for TCP streams and sessions.
.SH SYNOPSIS
.br
.PP
\fC#include <socket.h>\fP
.PP
Inherits \fBSocket\fP.
.PP
.SS "Public Methods"
.in +1c
.ti -1c
.RI "\fBTCPSocket\fP (const \fBInetAddress\fP &bind, \fBtpport_t\fP port, int backlog=5)"
.br
.RI "\fIA 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.\fP"
.ti -1c
.RI "\fBInetHostAddress\fP \fBgetRequest\fP (\fBtpport_t\fP *port=NULL) const"
.br
.RI "\fIReturn address and port of next connection request.\fP"
.ti -1c
.RI "void \fBreject\fP (void)"
.br
.RI "\fIUsed to reject the next incoming connection request.\fP"
.ti -1c
.RI "\fBInetHostAddress\fP \fBgetLocal\fP (\fBtpport_t\fP *port=NULL) const"
.br
.RI "\fIUsed to get local bound address.\fP"
.ti -1c
.RI "bool \fBisPendingConnection\fP (\fBtimeout_t\fP timeout=TIMEOUT_INF)"
.br
.RI "\fIUsed to wait for pending connection requests.\fP"
.ti -1c
.RI "virtual \fB~TCPSocket\fP ()"
.br
.RI "\fIUse base socket handler for ending this socket.\fP"
.in -1c
.SS "Protected Methods"
.in +1c
.ti -1c
.RI "virtual bool \fBonAccept\fP (const \fBInetHostAddress\fP &ia, \fBtpport_t\fP port)"
.br
.RI "\fIA method to call in a derived TCPSocket class that is acting as a server when a connection request is being accepted.\fP"
.in -1c
.SS "Friends"
.in +1c
.ti -1c
.RI "class \fBTCPStream\fP"
.br
.ti -1c
.RI "class \fBSocketPort\fP"
.br
.ti -1c
.RI "class \fBtcpstream\fP"
.br
.in -1c
.SH "DETAILED DESCRIPTION"
.PP
TCP sockets are used for stream based connected sessions between two sockets. bound server for TCP streams and sessions.
.PP
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.
.PP
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 \fBTCPStream\fP 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.
.PP
The TCPSocket also supports a 'OnAccept' method which can be called when a \fBTCPStream\fP related object is created from a TCPSocket. By creating a \fBTCPStream\fP 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.
.PP
\fBAuthor: \fP
.in +1c
David Sugar <dyfet@tycho.com>
.PP
.SH "CONSTRUCTOR & DESTRUCTOR DOCUMENTATION"
.PP
.SS "TCPSocket::TCPSocket (const \fBInetAddress\fP & bind, \fBtpport_t\fP port, int backlog = 5)"
.PP
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.
.PP
If the server cannot be created, an exception is thrown.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIbind\fP\fP
local ip address or interface to use.
.TP
\fB\fIport\fP\fP
number to bind socket under.
.TP
\fB\fIbacklog\fP\fP
size of connection request queue.
.SS "virtual TCPSocket::~TCPSocket ()\fC [inline, virtual]\fP"
.PP
Use base socket handler for ending this socket.
.PP
.SH "MEMBER FUNCTION DOCUMENTATION"
.PP
.SS "\fBInetHostAddress\fP TCPSocket::getLocal (\fBtpport_t\fP * port = NULL) const\fC [inline]\fP"
.PP
Used to get local bound address.
.PP
Reimplemented from \fBSocket\fP.
.SS "\fBInetHostAddress\fP TCPSocket::getRequest (\fBtpport_t\fP * port = NULL) const\fC [inline]\fP"
.PP
Return address and port of next connection request.
.PP
This can be used instead of OnAccept() to pre-evaluate connection requests.
.PP
\fBReturns: \fP
.in +1c
host requesting a connection.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIport\fP\fP
number of requestor.
.SS "bool TCPSocket::isPendingConnection (\fBtimeout_t\fP timeout = TIMEOUT_INF)\fC [inline]\fP"
.PP
Used to wait for pending connection requests.
.PP
\fBReturns: \fP
.in +1c
true if data packets available.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fItimeout\fP\fP
in milliseconds. TIMEOUT_INF if not specified.
.SS "virtual bool TCPSocket::onAccept (const \fBInetHostAddress\fP & ia, \fBtpport_t\fP port)\fC [inline, protected, virtual]\fP"
.PP
A method to call in a derived TCPSocket class that is acting as a server when a connection request is being accepted.
.PP
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.
.PP
\fBReturns: \fP
.in +1c
true if client should be accepted.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIia\fP\fP
internet host address of the client.
.TP
\fB\fIport\fP\fP
number of the client.
.SS "void TCPSocket::reject (void)"
.PP
Used to reject the next incoming connection request.
.PP
.SH "FRIENDS AND RELATED FUNCTION DOCUMENTATION"
.PP
.SS "friend class SocketPort\fC [friend]\fP"
.PP
.SS "friend class tcpstream\fC [friend]\fP"
.PP
.SS "friend class TCPStream\fC [friend]\fP"
.PP
.SH "AUTHOR"
.PP
Generated automatically by Doxygen for CommonC++ from the source code.
|