SocketGUS
Fork of Socket by
Diff: Socket.h
- Revision:
- 6:cd2e5559786d
- Parent:
- 5:300e7ad2dc1d
- Child:
- 8:9cf9c2d45264
--- a/Socket.h Thu Jul 26 15:07:32 2012 +0000 +++ b/Socket.h Fri Jul 27 13:58:53 2012 +0000 @@ -30,6 +30,8 @@ return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); } +class TimeInterval; + class Socket { public: Socket(); @@ -40,15 +42,21 @@ int _sock_fd; int init_socket(int type); - void set_timeout(int timeout); - int wait_readable(void); - int wait_writable(void); + int wait_readable(TimeInterval& timeout); + int wait_writable(TimeInterval& timeout); private: - // At the moment, we assume a simple single threaded access to the socket - struct timeval _timeout; - fd_set _fdSet; - int select(fd_set* readset, fd_set* writeset); + int select(struct timeval *timeout, bool read, bool write); +}; + +class TimeInterval { + friend class Socket; + +public: + TimeInterval(int ms); + +private: + struct timeval _time; }; #endif /* SOCKET_H_ */