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

37
net/test_server.cpp Normal file
View file

@ -0,0 +1,37 @@
#include <iostream>
#include <string>
#include "socket.h"
#include "serversocket.h"
#include "socketexception.h"
using namespace std;
using namespace zutil;
int main ( int argc, int argv[] ){
cout << "running....\n";
try{
// Create the socket
ServerSocket server ( 30000 );
while ( true ){
Socket new_sock;
server.accept ( new_sock );
istream &in = new_sock.get_istream();
ostream &out = new_sock.get_ostream();
try{
while ( true ){
string data;
in >> data;
cout << data << endl;
out << data;
}
}catch ( SocketException& ) {}
}
}catch ( SocketException& e ){
cout << "Exception was caught:" << e.description() << "\nExiting.\n";
}
return 0;
}