cpp utils files, network and a smal util class

This commit is contained in:
Ziver Koc 2009-11-21 01:11:05 +00:00
parent ea3dffdb4a
commit 62f50a2f79
13 changed files with 610 additions and 0 deletions

27
net/serversocket.cpp Normal file
View file

@ -0,0 +1,27 @@
#include "serversocket.h"
using namespace zutil;
ServerSocket::ServerSocket( int port ){
if ( !SocketIO::create() ){
throw SocketException ( "Could not create server socket." );
}
if ( !Socket::bind( port ) ){
throw SocketException ( "Could not bind to port." );
}
if ( !Socket::listen() ){
throw SocketException ( "Could not listen to socket." );
}
}
Socket* ServerSocket::accept( ){
Socket *sock = new Socket();
accept(*sock);
return sock;
}
void ServerSocket::accept( Socket& sock ){
if ( !SocketIO::accept( sock ) ){
throw SocketException ( "Could not accept socket." );
}
}