Revision 66, 0.5 KB
(checked in by ahe, 16 years ago)
|
update socket
|
Rev | Line | |
---|
[35] | 1 | #include "ClientSocket.h" |
---|
| 2 | #include "SocketException.h" |
---|
| 3 | #include <iostream> |
---|
| 4 | #include <string> |
---|
| 5 | |
---|
| 6 | int main ( int argc, int argv[] ) |
---|
| 7 | { |
---|
| 8 | try |
---|
| 9 | { |
---|
| 10 | |
---|
[66] | 11 | ClientSocket client_socket ( "localhost", 30001 ); |
---|
[35] | 12 | |
---|
| 13 | std::string reply; |
---|
| 14 | |
---|
[65] | 15 | while(1) { |
---|
[35] | 16 | try |
---|
| 17 | { |
---|
| 18 | client_socket >> reply; |
---|
| 19 | } |
---|
| 20 | catch ( SocketException& ) {} |
---|
| 21 | |
---|
| 22 | std::cout << "We received this response from the server:\n\"" << reply << "\"\n";; |
---|
| 23 | |
---|
| 24 | } |
---|
[65] | 25 | } |
---|
[35] | 26 | catch ( SocketException& e ) |
---|
| 27 | { |
---|
| 28 | std::cout << "Exception was caught:" << e.description() << "\n"; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | return 0; |
---|
| 32 | } |
---|