6 #include <sys/socket.h>
7 #include <netinet/in.h>
11 #include <lib/base/ebase.h>
12 #include <lib/base/eerror.h>
14 #include <libsig_comp.h>
15 #include <lib/base/buffer.h>
17 class eSocket: public Object
21 unsigned int last_break;
25 eIOBuffer writebuffer;
27 sockaddr_in serv_addr;
30 virtual void notifier(int);
32 eSocket(eMainloop *ml);
33 eSocket(int socket, int issocket, eMainloop *ml);
35 int connectToHost(std::string hostname, int port);
37 int writeBlock(const char *data, unsigned int len);
38 int setSocket(int socketfd, int issocket, eMainloop *ml);
40 int readBlock(char *data, unsigned int maxlen);
43 std::string readLine();
45 // flow control: start/stop data delivery into read buffer.
49 void inject(const char *data, int len);
51 enum State { Idle, HostLookup, Connecting,
52 Listening, Connection, Closing };
55 Signal0<void> connectionClosed_;
56 Signal0<void> connected_;
57 Signal0<void> readyRead_;
59 Signal1<void,int> bytesWritten_;
60 Signal1<void,int> error_;
63 #endif /* __socket_h */