1 #ifndef __DOM_SOCKET_H__
2 #define __DOM_SOCKET_H__
3 /**
4 * Phoebe DOM Implementation.
5 *
6 * This is a C++ approximation of the W3C DOM model, which follows
7 * fairly closely the specifications in the various .idl files, copies of
8 * which are provided for reference. Most important is this one:
9 *
10 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11 *
12 * Authors:
13 * Bob Jamison
14 *
15 * Copyright (C) 2005 Bob Jamison
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
32 #include "dom/dom.h"
35 namespace org
36 {
37 namespace w3c
38 {
39 namespace dom
40 {
41 namespace io
42 {
44 class TcpSocket
45 {
46 public:
48 TcpSocket();
50 TcpSocket(const DOMString &hostname, int port);
52 TcpSocket(const TcpSocket &other);
54 virtual ~TcpSocket();
56 bool isConnected();
58 void enableSSL(bool val);
60 bool connect(const DOMString &hostname, int portno);
62 bool startTls();
64 bool connect();
66 bool disconnect();
68 bool setReceiveTimeout(unsigned long millis);
70 long available();
72 bool write(int ch);
74 bool write(const DOMString &str);
76 int read();
78 bool readLine(DOMString &result);
80 private:
82 void init();
84 DOMString hostname;
85 int portno;
86 int sock;
87 bool connected;
89 bool sslEnabled;
91 unsigned long receiveTimeout;
93 #ifdef HAVE_SSL
94 SSL_CTX *sslContext;
95 SSL *sslStream;
96 #endif
98 };
103 } //namespace io
104 } //namespace dom
105 } //namespace w3c
106 } //namespace org
108 #endif /* __DOM_SOCKET_H__ */
109 //#########################################################################
110 //# E N D O F F I L E
111 //#########################################################################