PTLib
Version 2.10.4
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
inetprot.h
Go to the documentation of this file.
1
/*
2
* inetprot.h
3
*
4
* Internet Protocol ancestor channel class
5
*
6
* Portable Windows Library
7
*
8
* Copyright (c) 1993-2002 Equivalence Pty. Ltd.
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Contributor(s): ______________________________________.
25
*
26
* $Revision: 24177 $
27
* $Author: rjongbloed $
28
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
29
*/
30
31
#ifndef PTLIB_INETPROT_H
32
#define PTLIB_INETPROT_H
33
34
#ifdef P_USE_PRAGMA
35
#pragma interface
36
#endif
37
38
39
class
PSocket
;
40
class
PIPSocket
;
41
42
62
class
PInternetProtocol
:
public
PIndirectChannel
63
{
64
PCLASSINFO
(
PInternetProtocol
,
PIndirectChannel
)
65
66
protected
:
67
PInternetProtocol
(
68
const
char
*
defaultServiceName
,
69
PINDEX cmdCount,
70
char
const
*
const
* cmdNames
71
);
72
// Create an unopened TCP/IP protocol socket channel.
73
74
75
public
:
76
// Overrides from class PChannel.
88
virtual
PBoolean
Read
(
89
void
* buf,
90
PINDEX len
91
);
92
108
virtual
PBoolean
Write
(
109
const
void
* buf,
110
PINDEX len
111
);
112
116
void
SetReadLineTimeout
(
117
const
PTimeInterval
& t
118
);
119
120
// New functions for class.
126
virtual
PBoolean
Connect
(
127
const
PString
& address,
128
WORD port = 0
129
);
130
virtual
PBoolean
Connect
(
131
const
PString
& address,
132
const
PString
& service
133
);
134
140
virtual
PBoolean
Accept
(
141
PSocket
& listener
142
);
143
150
const
PString
&
GetDefaultService
()
const
;
151
160
PIPSocket
*
GetSocket
()
const
;
161
169
virtual
PBoolean
WriteLine
(
170
const
PString
& line
171
);
172
189
virtual
PBoolean
ReadLine
(
190
PString
& line,
191
PBoolean
allowContinuation =
false
192
);
193
197
virtual
void
UnRead
(
198
int
ch
199
);
200
virtual
void
UnRead
(
201
const
PString
& str
202
);
203
virtual
void
UnRead
(
204
const
void
* buffer,
205
PINDEX len
206
);
207
221
virtual
PBoolean
WriteCommand
(
222
PINDEX cmdNumber
223
);
224
virtual
PBoolean
WriteCommand
(
225
PINDEX cmdNumber,
226
const
PString
& param
227
);
228
246
virtual
PBoolean
ReadCommand
(
247
PINDEX & num,
250
PString
& args
251
);
252
269
virtual
PBoolean
WriteResponse
(
270
unsigned
numericCode,
271
const
PString
& info
272
);
273
virtual
PBoolean
WriteResponse
(
274
const
PString
& code,
275
const
PString
& info
276
);
277
296
virtual
PBoolean
ReadResponse
();
297
virtual
PBoolean
ReadResponse
(
298
int
& code,
299
PString
& info
300
);
301
313
virtual
int
ExecuteCommand
(
314
PINDEX cmdNumber
315
);
316
virtual
int
ExecuteCommand
(
317
PINDEX cmdNumber,
318
const
PString
& param
319
);
320
327
int
GetLastResponseCode
()
const
;
328
334
PString
GetLastResponseInfo
()
const
;
335
336
337
protected
:
349
virtual
PINDEX
ParseResponse
(
350
const
PString
& line
351
);
352
353
354
PString
defaultServiceName
;
355
// Default Service name to use for the internet protocol socket.
356
357
PStringArray
commandNames
;
358
// Names of each of the command codes.
359
360
PCharArray
unReadBuffer
;
361
// Buffer for characters put back into the data stream.
362
363
PINDEX
unReadCount
;
364
// Buffer count for characters put back into the data stream.
365
366
PTimeInterval
readLineTimeout
;
367
// Time for characters in a line to be received.
368
369
enum
StuffState
{
370
DontStuff
,
StuffIdle
,
StuffCR
,
StuffCRLF
,
StuffCRLFdot
,
StuffCRLFdotCR
371
}
stuffingState
;
372
// Do byte stuffing of '.' characters in output to the socket channel.
373
374
PBoolean
newLineToCRLF
;
375
// Translate \\n characters to CR/LF pairs.
376
377
int
lastResponseCode
;
378
PString
lastResponseInfo
;
379
// Responses
380
381
private
:
382
PBoolean
AttachSocket(
PIPSocket
* socket);
383
};
384
385
386
387
#endif // PTLIB_INETPROT_H
388
389
390
// End Of File ///////////////////////////////////////////////////////////////
include
ptclib
inetprot.h
Generated on Tue Mar 11 2014 15:09:29 for PTLib by
1.8.1.2