From: Christian P. <cp...@us...> - 2005-01-26 10:23:26
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24824/include/pclasses/Net Modified Files: Socket.h Log Message: Added export-macros. Added "static int Socket::wait()" for waiting on a number of sockets. Index: Socket.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Net/Socket.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Socket.h 24 Jan 2005 23:00:39 -0000 1.5 +++ Socket.h 26 Jan 2005 10:23:17 -0000 1.6 @@ -21,6 +21,7 @@ #ifndef P_Net_Socket_h #define P_Net_Socket_h +#include <pclasses/Export.h> #include <pclasses/BasicTypes.h> #include <pclasses/IO/IODevice.h> #include <pclasses/Net/NetworkAddress.h> @@ -32,7 +33,7 @@ typedef uint16_t port_t; //! Socket -class Socket: public IO::IODevice { +class PNET_EXPORT Socket: public IO::IODevice { public: enum Domain { Inet, @@ -53,7 +54,7 @@ }; Socket() throw(); - Socket(Domain domain, Type type, int proto) throw(IO::IOError); + Socket(Domain domain, Type type, int proto = 0) throw(IO::IOError); ~Socket() throw(); Domain domain() const throw(); @@ -62,16 +63,11 @@ int protocol() const throw(); - int wait(int wait, unsigned int timeout) throw(IO::IOError); - //! Bind socket to given address and port void bind(const NetworkAddress& addr, port_t port) throw(IO::IOError); void connect(const NetworkAddress& addr, port_t port) throw(IO::IOError); - void listen() throw(IO::IOError); - Socket accept() throw(IO::IOError); - void setSendTimeout(unsigned int timeout) throw(IO::IOError); unsigned int sendTimeout() const throw(IO::IOError); @@ -88,6 +84,13 @@ void setRouting(bool enable) throw(IO::IOError); + int wait(int wait, unsigned int timeout) throw(IO::IOError); + + static int wait(Socket* s[], int wait[], int num, unsigned int timeout) + throw(IO::IOError); + + static Domain addrFamily2Domain(int family); + protected: void open(Domain domain, Type type, int proto) throw(IO::IOError); @@ -95,20 +98,14 @@ void open(int handle, Domain domain, Type type, int proto) throw(IO::IOError); - void _close() throw(IO::IOError); + int handle() const throw(); + // IODevice related methods + void _close() throw(IO::IOError); size_t _read(char* buffer, size_t count) throw(IO::IOError); - size_t _peek(char* buffer, size_t count) throw(IO::IOError); - size_t _write(const char* buffer, size_t count) throw(IO::IOError); - int handle() const throw(); - - void addListener(IO::IOListener& l); - void updateListener(IO::IOListener& l); - void removeListener(IO::IOListener& l); - private: Domain _domain; Type _type; @@ -117,7 +114,7 @@ }; //! Datagram Socket -class DatagramSocket: public virtual Socket { +class PNET_EXPORT DatagramSocket: public virtual Socket { public: DatagramSocket() throw(); ~DatagramSocket() throw(); @@ -127,14 +124,40 @@ }; +//! Streaming Socket Server +class PNET_EXPORT StreamSocketServer: public Socket { + public: + //! Standard constructor + StreamSocketServer(Domain domain, int proto = 0) throw(IO::IOError); + + //! Binding constructor + StreamSocketServer(const NetworkAddress& addr, port_t port) throw(IO::IOError); + + ~StreamSocketServer() throw(); + + //! Bind socket to given address and port + void bind(const NetworkAddress& addr, port_t port) throw(IO::IOError); + + //! Listen for incoming connections + void listen() throw(IO::IOError); + + bool wait(unsigned int timeout) throw(IO::IOError); + + //! Accept incoming connection + int accept() throw(IO::IOError); +}; + //! Streaming Socket -class StreamSocket: public virtual Socket { +class PNET_EXPORT StreamSocket: public virtual Socket { public: StreamSocket() throw(); + StreamSocket(StreamSocketServer& srv) throw(IO::IOError); ~StreamSocket() throw(); + void open(StreamSocketServer& srv) throw(IO::IOError); }; + } // !namespace Net } // !namespace P |