Revision 38, 0.6 KB
(checked in by ahe, 16 years ago)
|
add files for client operation
|
Rev | Line | |
---|
[38] | 1 | #include "ServerSocket.h" |
---|
| 2 | #include "SocketException.h" |
---|
| 3 | #include <string> |
---|
| 4 | #include <iostream> |
---|
| 5 | |
---|
| 6 | int main ( int argc, int argv[] ) |
---|
| 7 | { |
---|
| 8 | std::cout << "running....\n"; |
---|
| 9 | |
---|
| 10 | try |
---|
| 11 | { |
---|
| 12 | // Create the socket |
---|
| 13 | ServerSocket server ( 30000 ); |
---|
| 14 | |
---|
| 15 | while ( true ) |
---|
| 16 | { |
---|
| 17 | |
---|
| 18 | ServerSocket new_sock; |
---|
| 19 | server.accept ( new_sock ); |
---|
| 20 | |
---|
| 21 | try |
---|
| 22 | { |
---|
| 23 | while ( true ) |
---|
| 24 | { |
---|
| 25 | std::string data; |
---|
| 26 | new_sock >> data; |
---|
| 27 | new_sock << data; |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | catch ( SocketException& ) {} |
---|
| 31 | |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | catch ( SocketException& e ) |
---|
| 35 | { |
---|
| 36 | std::cout << "Exception was caught:" << e.description() << "\nExiting.\n"; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | return 0; |
---|
| 40 | } |
---|