removed unused code
[enigma2.git] / lib / network / socket.h
1 #ifndef __socket_h
2 #define __socket_h
3
4 #include <stdio.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <netdb.h>
9 #include <fcntl.h>
10
11 #include <lib/base/ebase.h>
12 #include <lib/base/eerror.h>
13 #include <string>
14 #include <libsig_comp.h>
15 #include <lib/base/buffer.h>
16
17 class eSocket: public Object
18 {
19         int mystate;
20         int issocket;
21         unsigned int last_break;
22 private:
23         int socketdesc;
24         eIOBuffer readbuffer;
25         eIOBuffer writebuffer;
26         int writebusy;
27         sockaddr_in  serv_addr;
28 protected:
29         eSocketNotifier *rsn;
30         virtual void notifier(int);
31 public:
32         eSocket(eMainloop *ml);
33         eSocket(int socket, int issocket, eMainloop *ml);
34         ~eSocket();
35         int connectToHost(std::string hostname, int port);
36         int getDescriptor();
37         int writeBlock(const char *data, unsigned int len);
38         int setSocket(int socketfd, int issocket, eMainloop *ml);
39         int bytesToWrite();
40         int readBlock(char *data, unsigned int maxlen);
41         int bytesAvailable();
42         bool canReadLine();
43         std::string readLine();
44         void close();
45                         // flow control: start/stop data delivery into read buffer.
46         void enableRead();
47         void disableRead();
48         
49         void inject(const char *data, int len);
50         
51         enum State {    Idle, HostLookup, Connecting,
52                         Listening, Connection, Closing };
53         int state();
54         
55         Signal0<void> connectionClosed_;
56         Signal0<void> connected_;
57         Signal0<void> readyRead_;
58         Signal0<void> hangup;
59         Signal1<void,int> bytesWritten_;
60         Signal1<void,int> error_;
61 };
62
63 #endif /* __socket_h */