37 lines
754 B
C++
37 lines
754 B
C++
#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;
|
|
}
|