File: TCPSession.3cc

package info (click to toggle)
libcommoncpp2 1.0.13-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,740 kB
  • ctags: 2,860
  • sloc: cpp: 18,857; sh: 8,451; ansic: 1,546; makefile: 299; xml: 5
file content (124 lines) | stat: -rw-r--r-- 4,654 bytes parent folder | download
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
.TH "TCPSession" 3 "19 Jul 2003" "CommonC++" \" -*- nroff -*-
.ad l
.nh
.SH NAME
TCPSession \- The TCP session is used to primarily to represent a client connection that can be managed on a seperate thread. Threaded streamable socket with non-blocking constructor. 
.SH SYNOPSIS
.br
.PP
\fC#include <socket.h>\fP
.PP
Inherits \fBTCPStream\fP, and \fBThread\fP.
.PP
.SS "Public Methods"

.in +1c
.ti -1c
.RI "\fBTCPSession\fP (const \fBInetHostAddress\fP &host, \fBtpport_t\fP port, int \fBsize\fP=512, int pri=0, int stack=0)"
.br
.RI "\fICreate a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread.\fP"
.ti -1c
.RI "\fBTCPSession\fP (\fBTCPSocket\fP &server, int \fBsize\fP=512, int pri=0, int stack=0)"
.br
.RI "\fICreate a TCP socket from a bound TCP server by accepting a pending connection from that server and execute a thread for the accepted connection.\fP"
.in -1c
.SS "Protected Methods"

.in +1c
.ti -1c
.RI "int \fBwaitConnection\fP (\fBtimeout_t\fP \fBtimeout\fP=TIMEOUT_INF)"
.br
.RI "\fINormally called during the thread Initial() method by default, this will wait for the socket connection to complete when connecting to a remote socket.\fP"
.ti -1c
.RI "\fBCCXX_MEMBER\fP (void) initial(void)"
.br
.RI "\fIThe initial method is used to esablish a connection when delayed completion is used.\fP"
.ti -1c
.RI "\fBCCXX_MEMBER\fP (void) final(void)"
.br
.RI "\fITCPSession derived objects can be freely created with 'new' and safely terminate their 'run' method on their own by self-deleting when the thread terminates.\fP"
.in -1c
.SH "DETAILED DESCRIPTION"
.PP 
The TCP session is used to primarily to represent a client connection that can be managed on a seperate thread. Threaded streamable socket with non-blocking constructor.
.PP
The TCP session also supports a non-blocking connection scheme which prevents blocking during the constructor and moving the process of completing a connection into the  thread that executes for the session.
.PP
\fBAuthor: \fP
.in +1c
David Sugar <dyfet@ostel.com> 
.PP
.SH "CONSTRUCTOR & DESTRUCTOR DOCUMENTATION"
.PP 
.SS "TCPSession::TCPSession (const \fBInetHostAddress\fP & host, \fBtpport_t\fP port, int size = 512, int pri = 0, int stack = 0)"
.PP
Create a TCP socket that will be connected to a remote TCP server and that will execute under it's own thread.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIhost\fP\fP
internet address of remote TCP server. 
.TP
\fB\fIport\fP\fP
number of remote server. 
.TP
\fB\fIsize\fP\fP
of streaming buffer. 
.TP
\fB\fIpri\fP\fP
execution priority relative to parent. 
.TP
\fB\fIstack\fP\fP
allocation needed on some platforms. 
.SS "TCPSession::TCPSession (\fBTCPSocket\fP & server, int size = 512, int pri = 0, int stack = 0)"
.PP
Create a TCP socket from a bound TCP server by accepting a pending connection from that server and execute a thread for the accepted connection.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIserver\fP\fP
tcp socket to accept a connection from. 
.TP
\fB\fIsize\fP\fP
of streaming buffer. 
.TP
\fB\fIpri\fP\fP
execution priority relative to parent. 
.TP
\fB\fIstack\fP\fP
allocation needed on some platforms. 
.SH "MEMBER FUNCTION DOCUMENTATION"
.PP 
.SS "TCPSession::CCXX_MEMBER (void)\fC [inline, protected]\fP"
.PP
TCPSession derived objects can be freely created with 'new' and safely terminate their 'run' method on their own by self-deleting when the thread terminates.
.PP
\fBNote: \fP
.in +1c
Since a thread cannot delete its own context or join itself, to make a TCPSession that is a self running object that self-deletes, one has to detach the associated thread by using \fBdetach()\fP instead of \fBstart()\fP. 
.SS "TCPSession::CCXX_MEMBER (void)\fC [protected]\fP"
.PP
The initial method is used to esablish a connection when delayed completion is used.
.PP
This assures the constructor terminates without having to wait for a connection request to complete. 
.SS "int TCPSession::waitConnection (\fBtimeout_t\fP timeout = TIMEOUT_INF)\fC [protected]\fP"
.PP
Normally called during the thread Initial() method by default, this will wait for the socket connection to complete when connecting to a remote socket.
.PP
One might wish to use \fBsetCompletion()\fP to change the socket back to blocking I/O calls after the connection completes. To implement the session one must create a derived class which implements \fBrun()\fP.
.PP
\fBReturns: \fP
.in +1c
0 if successful, -1 if timed out. 
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fItimeout\fP\fP
to wait for completion in milliseconds. 

.SH "AUTHOR"
.PP 
Generated automatically by Doxygen for CommonC++ from the source code.