Add gnulib gettext module for config.rpath
[clinton/bobotpp.git] / source / Socket.H
CommitLineData
cb21075d 1// Socket.H -*- C++ -*-
2// Copyright (c) 1997, 1998 Etienne BERNARD
3
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// any later version.
8
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
39b022cb 16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
cb21075d 17
18#ifndef SOCKET_H
19#define SOCKET_H
20
cb21075d 21#include "String.H"
22
23class Socket {
24 struct s_fd {
25 int fd; // the data
26 int n; // reference counter
27 s_fd() { n = 1; }
28 };
29 s_fd *fd;
30
31 int remotePort;
32 unsigned long remoteAddress;
33
34 int localPort;
35 unsigned long localAddress;
36
37 int begin, end;
38
cb21075d 39
40public:
41 Socket();
42 Socket(int, unsigned long, int);
43 Socket(const Socket &);
44
45 ~Socket();
46
47 int getRemotePort() const;
48 int getLocalPort() const;
49 int getFileDescriptor() const;
50
51 bool isConnected();
52
53 bool setRemoteHostname(String);
54 bool setRemoteIP(unsigned long);
55 bool setRemotePort(int);
56
57 bool setLocalHostname(String);
58 bool setLocalIP(unsigned long);
59 bool setLocalPort(int);
60
61 bool setNonBlocking(bool = true);
62
63 bool connect();
64 bool listen(int = 5);
65 Socket accept();
66 void close();
67
68 bool write(String, bool = false);
69 String readLine();
70 String readChar();
71 bool hasData();
72private:
73 Socket(Socket &);
74};
75
76#endif