Line | |
---|
1 | #include "ServerSocket.h"
|
---|
2 | #include "SocketException.h"
|
---|
3 | #include <string>
|
---|
4 |
|
---|
5 | int main ( int argc, int argv[] )
|
---|
6 | {
|
---|
7 | std::cout << "running....\n";
|
---|
8 |
|
---|
9 | try
|
---|
10 | {
|
---|
11 | // Create the socket
|
---|
12 | ServerSocket server ( 8000 );
|
---|
13 |
|
---|
14 | while ( true )
|
---|
15 | {
|
---|
16 |
|
---|
17 | ServerSocket new_sock;
|
---|
18 | server.accept ( new_sock );
|
---|
19 |
|
---|
20 | try
|
---|
21 | {
|
---|
22 | while ( true )
|
---|
23 | {
|
---|
24 | std::string data;
|
---|
25 | new_sock >> data;
|
---|
26 | std::cout << data << "\n";
|
---|
27 | new_sock << "du serveur\n";
|
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.