Added signal handling to smtp, nailed many memory leaks on SearchTree, WorkerThread...
[fmail.git] / include / libfmail / socket.h
bloba56a8d4b9d06874e9ae165bebac4a3561126a03c
1 /*
2 libfmail: Socket abstraction
4 Copyright (C) 2007 Carlos Daniel Ruvalcaba Valenzuela <clsdaniel@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 enum {SOCKET_INET = 1, SOCKET_UNIX = 2};
22 enum {SOCKET_POLL_READ = 1, SOCKET_POLL_WRITE = 2, SOCKET_POLL_ERROR = 4};
23 enum {SOCKET_NONBLOCK = 1};
25 class Socket{
26 public:
27 static Socket *CreateSocket(int socktype, int options);
28 virtual ~Socket(){}
29 virtual void setPort(int port) = 0;
30 virtual int getPort() = 0;
31 virtual void setAddress(const char *addr) = 0;
32 virtual char *getAddress() = 0;
34 virtual int Connect() = 0;
35 virtual int Close() = 0;
36 virtual int Bind() = 0;
37 virtual int Listen(int queue) = 0;
38 virtual Socket *Accept() = 0;
40 virtual int Write(const char *buffer, int len) = 0;
41 virtual int Read(char *buffer, int len) = 0;
42 virtual int Poll(int ms, int mode) = 0;