From: Christian P. <cp...@us...> - 2004-12-23 04:32:31
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14702/src/Net Modified Files: InetAddress.cpp InetSocket.cpp Socket.cpp SocketOption.h Log Message: Moved IODevice, IOError into P::IO namespace. Moved Char, String, TextStream into P::Unicode namespace. Index: Socket.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/Socket.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Socket.cpp 22 Dec 2004 17:54:35 -0000 1.1.1.1 +++ Socket.cpp 23 Dec 2004 04:32:18 -0000 1.2 @@ -160,7 +160,7 @@ { } -Socket::Socket(Domain domain, Type type, int proto) throw(IOError) +Socket::Socket(Domain domain, Type type, int proto) throw(IO::IOError) : IODevice(), _handle(-1) { open(domain, type, proto); @@ -196,7 +196,7 @@ } void Socket::open(Domain domain, Type type, int proto) - throw(LogicError, IOError) + throw(LogicError, IO::IOError) { if(!valid()) { @@ -230,7 +230,7 @@ int ret = ::socket(d, t, proto); if(ret == -1) - throw IOError(errno, "Could not open socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not open socket", P_SOURCEINFO); IODevice::setAccess(ReadWrite); IODevice::setValid(true); @@ -247,13 +247,13 @@ throw LogicError("Socket is already open", P_SOURCEINFO); } -void Socket::close() throw(LogicError, IOError) +void Socket::close() throw(LogicError, IO::IOError) { if(valid()) { int ret = ::close(_handle); if(ret == -1) - throw IOError(errno, "Could not close socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not close socket", P_SOURCEINFO); IODevice::setAccess(None); IODevice::setValid(false); @@ -263,12 +263,12 @@ throw LogicError("Socket is not open", P_SOURCEINFO); } -size_t Socket::read(char* buffer, size_t count) throw(IOError) +size_t Socket::read(char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::recv(_handle, (void*)buffer, count, MSG_NOSIGNAL); if(ret == -1) { - throw IOError(errno, "Could not read from socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not read from socket", P_SOURCEINFO); } else if(ret == 0 && !eof()) setEof(true); @@ -276,28 +276,28 @@ return ret; } -size_t Socket::peek(char* buffer, size_t count) throw(IOError) +size_t Socket::peek(char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::recv(_handle, (void*)buffer, count, MSG_PEEK|MSG_NOSIGNAL); if(ret == -1) - throw IOError(errno, "Could not read from socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not read from socket", P_SOURCEINFO); return ret; } -size_t Socket::write(const char* buffer, size_t count) throw(IOError) +size_t Socket::write(const char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::send(_handle, (const void*)buffer, count, MSG_NOSIGNAL); if(ret == -1) - throw IOError(errno, "Could not write to socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not write to socket", P_SOURCEINFO); return ret; } -int Socket::wait(int wait, unsigned int timeout) throw(IOError) +int Socket::wait(int wait, unsigned int timeout) throw(IO::IOError) { fd_set readFds, writeFds; @@ -324,7 +324,7 @@ if(errno == EINTR) goto select_loop; - throw IOError(errno, "Could not write to socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not write to socket", P_SOURCEINFO); } ret = 0; @@ -338,7 +338,7 @@ return ret; } -void Socket::bind(const NetworkAddress& addr, port_t port) throw(IOError) +void Socket::bind(const NetworkAddress& addr, port_t port) throw(IO::IOError) { size_t socketAddrLen = 0; sockaddr* socketAddr = makeSocketAddress(addr, port, socketAddrLen); @@ -347,58 +347,58 @@ delete socketAddr; if(ret == -1) - throw IOError(errno, "Could not bind address to socket", P_SOURCEINFO); + throw IO::IOError(errno, "Could not bind address to socket", P_SOURCEINFO); } -void Socket::setSendTimeout(unsigned int timeout) throw(IOError) +void Socket::setSendTimeout(unsigned int timeout) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_SNDTIMEO, int> opt(_handle); opt.set(timeout); } -unsigned int Socket::sendTimeout() const throw(IOError) +unsigned int Socket::sendTimeout() const throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_SNDTIMEO, int> opt(_handle); return opt.get(); } -void Socket::setReceiveTimeout(unsigned int timeout) throw(IOError) +void Socket::setReceiveTimeout(unsigned int timeout) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_RCVTIMEO, int> opt(_handle); opt.set(timeout); } -unsigned int Socket::receiveTimeout() const throw(IOError) +unsigned int Socket::receiveTimeout() const throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_RCVTIMEO, int> opt(_handle); return opt.get(); } -void Socket::setSendBufferSize(size_t sz) throw(IOError) +void Socket::setSendBufferSize(size_t sz) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_SNDBUF, int> opt(_handle); opt.set(sz); } -size_t Socket::sendBufferSize() const throw(IOError) +size_t Socket::sendBufferSize() const throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_SNDBUF, int> opt(_handle); return opt.get(); } -void Socket::setReceiveBufferSize(size_t sz) throw(IOError) +void Socket::setReceiveBufferSize(size_t sz) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_RCVBUF, int> opt(_handle); opt.set(sz); } -size_t Socket::receiveBufferSize() const throw(IOError) +size_t Socket::receiveBufferSize() const throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_RCVBUF, int> opt(_handle); return opt.get(); } -void Socket::setLinger(bool enable, unsigned int timeout) throw(IOError) +void Socket::setLinger(bool enable, unsigned int timeout) throw(IO::IOError) { linger lopt; lopt.l_onoff = enable ? 1 : 0; @@ -408,7 +408,7 @@ opt.set(lopt); } -void Socket::setRouting(bool enable) throw(IOError) +void Socket::setRouting(bool enable) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_DONTROUTE, int> opt(_handle); opt.set(enable ? 1 : 0); @@ -419,15 +419,15 @@ return _handle; } -void Socket::addListener(IOListener& l) +void Socket::addListener(IO::IOListener& l) { } -void Socket::updateListener(IOListener& l) +void Socket::updateListener(IO::IOListener& l) { } -void Socket::removeListener(IOListener& l) +void Socket::removeListener(IO::IOListener& l) { } @@ -441,13 +441,13 @@ { } -void DatagramSocket::setBroadcast(bool enable) throw(IOError) +void DatagramSocket::setBroadcast(bool enable) throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_BROADCAST, int> opt(handle()); opt.set(enable ? 1 : 0); } -bool DatagramSocket::broadcast() const throw(IOError) +bool DatagramSocket::broadcast() const throw(IO::IOError) { SocketOption<SOL_SOCKET, SO_BROADCAST, int> opt(handle()); return opt.get() == 1 ? true : false; Index: InetAddress.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/InetAddress.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- InetAddress.cpp 22 Dec 2004 17:54:34 -0000 1.1.1.1 +++ InetAddress.cpp 23 Dec 2004 04:32:18 -0000 1.2 @@ -61,7 +61,7 @@ return (*this == InetAddress(Loopback)); } -String InetAddress::str() const +Unicode::String InetAddress::str() const { //@todo InetAddress::str() } Index: SocketOption.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/SocketOption.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- SocketOption.h 22 Dec 2004 17:54:35 -0000 1.1.1.1 +++ SocketOption.h 23 Dec 2004 04:32:18 -0000 1.2 @@ -18,9 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_SocketOption_h_ -#define _P_SocketOption_h_ +#ifndef P_Net_SocketOption_h +#define P_Net_SocketOption_h +#include "pclasses/IO/IOError.h" #include <errno.h> namespace P { @@ -39,7 +40,7 @@ sizeof(Type)); if(ret == -1) - throw IOError(errno, "Could not set socket option", P_SOURCEINFO); + throw IO::IOError(errno, "Could not set socket option", P_SOURCEINFO); } inline Type get() @@ -50,7 +51,7 @@ &len); if(ret == -1) - throw IOError(errno, "Could not get socket option", P_SOURCEINFO); + throw IO::IOError(errno, "Could not get socket option", P_SOURCEINFO); return val; } Index: InetSocket.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/InetSocket.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- InetSocket.cpp 22 Dec 2004 17:54:35 -0000 1.1.1.1 +++ InetSocket.cpp 23 Dec 2004 04:32:18 -0000 1.2 @@ -35,7 +35,7 @@ { } -InetSocket::InetSocket(Type t, int proto) throw(IOError) +InetSocket::InetSocket(Type t, int proto) throw(IO::IOError) : Socket(Socket::Inet, t, proto) { } @@ -44,37 +44,37 @@ { } -void InetSocket::open(Type type, int proto) throw(LogicError, IOError) +void InetSocket::open(Type type, int proto) throw(LogicError, IO::IOError) { Socket::open(Socket::Inet, type, proto); } -void InetSocket::setTypeOfSerice(uint8_t type) throw(IOError) +void InetSocket::setTypeOfSerice(uint8_t type) throw(IO::IOError) { SocketOption<SOL_IP, IP_TOS, uint8_t> opt(handle()); opt.set(type); } -uint8_t InetSocket::typeOfService() const throw(IOError) +uint8_t InetSocket::typeOfService() const throw(IO::IOError) { SocketOption<SOL_IP, IP_TOS, uint8_t> opt(handle()); return opt.get(); } -void InetSocket::setTimeToLive(int ttl) throw(IOError) +void InetSocket::setTimeToLive(int ttl) throw(IO::IOError) { SocketOption<SOL_IP, IP_TTL, int> opt(handle()); opt.set(ttl); } -int InetSocket::timeToLive() const throw(IOError) +int InetSocket::timeToLive() const throw(IO::IOError) { SocketOption<SOL_IP, IP_TTL, int> opt(handle()); return opt.get(); } -UDPSocket::UDPSocket() throw(IOError) +UDPSocket::UDPSocket() throw(IO::IOError) : InetSocket(), DatagramSocket() { InetSocket::open(Socket::Datagram, IPPROTO_UDP); @@ -84,36 +84,36 @@ { } -void UDPSocket::open() throw(LogicError, IOError) +void UDPSocket::open() throw(LogicError, IO::IOError) { InetSocket::open(Socket::Datagram, IPPROTO_UDP); } -void UDPSocket::setMulticastTTL(int ttl) throw(IOError) +void UDPSocket::setMulticastTTL(int ttl) throw(IO::IOError) { SocketOption<SOL_IP, IP_MULTICAST_TTL, int> opt(handle()); opt.set(ttl); } -int UDPSocket::multicastTTL() const throw(IOError) +int UDPSocket::multicastTTL() const throw(IO::IOError) { SocketOption<SOL_IP, IP_MULTICAST_TTL, int> opt(handle()); return opt.get(); } -void UDPSocket::setMulticastLoop(bool enable) throw(IOError) +void UDPSocket::setMulticastLoop(bool enable) throw(IO::IOError) { SocketOption<SOL_IP, IP_MULTICAST_LOOP, int> opt(handle()); opt.set(enable ? 1 : 0); } -bool UDPSocket::multicastLoop() const throw(IOError) +bool UDPSocket::multicastLoop() const throw(IO::IOError) { SocketOption<SOL_IP, IP_MULTICAST_LOOP, int> opt(handle()); return opt.get(); } -void UDPSocket::addMembership(const InetAddress& addr) throw(IOError) +void UDPSocket::addMembership(const InetAddress& addr) throw(IO::IOError) { InetAddress anyAddr(InetAddress::Any); @@ -135,7 +135,7 @@ #endif } -void UDPSocket::dropMembership(const InetAddress& addr) throw(IOError) +void UDPSocket::dropMembership(const InetAddress& addr) throw(IO::IOError) { InetAddress anyAddr(InetAddress::Any); @@ -158,7 +158,7 @@ } -TCPSocket::TCPSocket() throw(IOError) +TCPSocket::TCPSocket() throw(IO::IOError) : InetSocket(), StreamSocket() { InetSocket::open(Socket::Stream, IPPROTO_TCP); @@ -168,7 +168,7 @@ { } -void TCPSocket::open() throw(LogicError, IOError) +void TCPSocket::open() throw(LogicError, IO::IOError) { InetSocket::open(Socket::Stream, IPPROTO_TCP); } |