| Line | |
|---|
| 1 | #include "ClientSocket.h"
|
|---|
| 2 | #include "SocketException.h"
|
|---|
| 3 | #include <iostream>
|
|---|
| 4 | #include <string>
|
|---|
| 5 | #include <stdio.h>
|
|---|
| 6 |
|
|---|
| 7 | int main ( int argc, int argv[] )
|
|---|
| 8 | {
|
|---|
| 9 | try
|
|---|
| 10 | {
|
|---|
| 11 |
|
|---|
| 12 | ClientSocket client_socket ( "192.168.0.1", 8000 );
|
|---|
| 13 |
|
|---|
| 14 | std::string reply;
|
|---|
| 15 | char chaine[20];
|
|---|
| 16 | int i=0;
|
|---|
| 17 |
|
|---|
| 18 | while(true)
|
|---|
| 19 | {
|
|---|
| 20 | i++;
|
|---|
| 21 | try
|
|---|
| 22 | {
|
|---|
| 23 | sprintf(chaine,"client %i-",i);
|
|---|
| 24 | client_socket << "Client : " << chaine << "\"\n";
|
|---|
| 25 | client_socket >> reply;
|
|---|
| 26 | }
|
|---|
| 27 | catch ( SocketException& e) {
|
|---|
| 28 | std::cout << e.description() << "\n";
|
|---|
| 29 | break;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | std::cout << reply ;
|
|---|
| 33 |
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | catch ( SocketException& e )
|
|---|
| 37 | {
|
|---|
| 38 | std::cout << "Exception was caught:" << e.description() << "\n";
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | return 0;
|
|---|
| 42 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.