Revision 35, 0.6 KB
(checked in by trnewman, 16 years ago)
|
adding c++
|
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 | |
---|
| 11 | ClientSocket client_socket ( "localhost", 30000 ); |
---|
| 12 | |
---|
| 13 | std::string reply; |
---|
| 14 | |
---|
| 15 | try |
---|
| 16 | { |
---|
| 17 | client_socket << "Test message."; |
---|
| 18 | client_socket >> reply; |
---|
| 19 | } |
---|
| 20 | catch ( SocketException& ) {} |
---|
| 21 | |
---|
| 22 | std::cout << "We received this response from the server:\n\"" << reply << "\"\n";; |
---|
| 23 | |
---|
| 24 | } |
---|
| 25 | catch ( SocketException& e ) |
---|
| 26 | { |
---|
| 27 | std::cout << "Exception was caught:" << e.description() << "\n"; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | return 0; |
---|
| 31 | } |
---|