- Code: Select all
[user@host current_pathname]$ g++ -g -I. -I/usr/local/include -I/usr/local/include/boost -L/usr/local/lib -lboost_locale -lboost_thread Main.cpp
In file included from Main.cpp:15:
Client.hpp: In member function ?void Client::HandleReadHeader(Client::MessagePtr, const boost::system::error_code&)?:
Client.hpp:211: error: ?Beep? was not declared in this scope
In file included from Main.cpp:15:
Client.hpp: In member function ?void Client::StartSendHeartbeat()?:
Client.hpp:348: error: ?Beep? was not declared in this scope
In file included from Main.cpp:16:
Server.hpp: In member function ?void ASyncConnectionMt::HandleReadBody(ASyncConnectionMt::MessagePtr, const boost::system::error_code&)?:
Server.hpp:192: error: no matching function for call to ?transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unresolved overloaded function type>)?
[user@host current_pathname]$
Beep() is a Windows function, but I'm running on Linux. I know how to make noise on Linux with echo, but I don't need that to see the program work. I comment out the lines with Beep() in them:
- Code: Select all
[user@host current_pathname]$ grep -n Beep *.[ch]pp
Client.hpp:211: Beep(1400, 200);
Client.hpp:348: Beep(700, 200);
[user@host current_pathname]$
- Code: Select all
[user@host current_pathname]$ g++ -g -I. -I/usr/local/include -I/usr/local/include/boost -L/usr/local/lib -lboost_locale -lboost_thread Main.cpp
In file included from Main.cpp:16:
Server.hpp: In member function ?void ASyncConnectionMt::HandleReadBody(ASyncConnectionMt::MessagePtr, const boost::system::error_code&)?:
Server.hpp:192: error: no matching function for call to ?transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unresolved overloaded function type>)?
[user@host current_pathname]$
The compiler can't find toupper. That is not a problem because I can live without a translation to upper case as evidence that a message reached the server. I comment out that line, and the compiler runs error free and links a binary.
I run the binary and type 2 to get the server running:
- Code: Select all
[user@host current_pathname]$ a.out
TCP networking example.
Debugging commands after connecting:
- ClientHeartbeatOn
- ServerHeartbeatOn
- ClientHeartbeatOff
- ServerHeartbeatOff
- ClientSendCrcError
- ServerSendCrcError
1. Client
2. Server
Choice: 2
(thread id: 7f8a09f3e720) Listening to TCP socket on port 60000...
That is excellent! Encouraged, I start the client and watch it fail:
- Code: Select all
[user@host current_pathname]$ a.out
TCP networking example.
Debugging commands after connecting:
- ClientHeartbeatOn
- ServerHeartbeatOn
- ClientHeartbeatOff
- ServerHeartbeatOff
- ClientSendCrcError
- ServerSendCrcError
1. Client
2. Server
Choice: 1
Enter the host to connect to (empty=localhost):
Debugging commands:
- ClientHeartbeatOff
- ClientHeartbeatOn
- ServerHeartbeatOff
- ServerHeartbeatOn
- ClientSendCrcError
- ServerSendCrcError
Connecting to 127.0.0.1:60000...
Connected to 127.0.0.1:60000
Enter text to send:
1234
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create
Aborted
[user@host current_pathname]$
Longer text or one of the commands elicits a different error:
- Code: Select all
[user@host current_pathname]$ a.out
TCP networking example.
Debugging commands after connecting:
- ClientHeartbeatOn
- ServerHeartbeatOn
- ClientHeartbeatOff
- ServerHeartbeatOff
- ClientSendCrcError
- ServerSendCrcError
1. Client
2. Server
Choice: 1
Enter the host to connect to (empty=localhost):
Debugging commands:
- ClientHeartbeatOff
- ClientHeartbeatOn
- ServerHeartbeatOff
- ServerHeartbeatOn
- ClientSendCrcError
- ServerSendCrcError
Connecting to 127.0.0.1:60000...
Connected to 127.0.0.1:60000
Enter text to send:
ServerHeartbeatOff
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
[user@host current_pathname]$
Please post a working copy of that sample program.