--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: TCPStream: Does only send one packet, if read from the stream
- From: Tobias Frost <tobi@coldtobi.de>
- Date: Sun, 07 Jun 2009 18:35:46 +0200
- Message-id: <20090607163546.1786.74028.reportbug@mordor.is-a-geek.net>
Package: libcommoncpp2-dev
Version: 1.7.3-1
Severity: normal
DESCRIPTION
I just disovered, that the class TCPStream does not work as expected.
When you do a "send -- receive -- send" , only one package is sent. The second send is not performed.
When you do a "send -- send" , two packages are sent, as expected.
TESTCASE
Attached are two testcases: test.cpp and test_noreceive.cpp
Compile it with e.g g++ test_noreceive.cpp `ccgnu2-config --flags --libs --includes`
The first does the send -- receive -- send, the second just has commented out the receive line.
To test it, use netcat -l -p 12345
SAMPLE OUTPUT
tobi@mordor:~/workspace/test$ g++ test.cpp `ccgnu2-config --flags --libs --includes --extlibs `
tobi@mordor:~/workspace/test$ netcat -l -p 12345 &
[1] 2124
tobi@mordor:~/workspace/test$ ./a.out
{FB;01;66|64:TYP;SWV;BDN;PAC;KHR;PIN;KT0;DDY;KYR;KMT;DMT;KT0;RPL;UDC;IDC;IL1;UL1;TKK;TMI;THR;SYS|1AAD}
tobi@mordor:~/workspace/test$ g++ test_noreceive.cpp `ccgnu2-config --flags --libs --includes --extlibs `
[1]+ Done netcat -l -p 12345
tobi@mordor:~/workspace/test$ netcat -l -p 12345 &
[1] 2151
tobi@mordor:~/workspace/test$ ./a.out
{FB;01;66|64:TYP;SWV;BDN;PAC;KHR;PIN;KT0;DDY;KYR;KMT;DMT;KT0;RPL;UDC;IDC;IL1;UL1;TKK;TMI;THR;SYS|1AAD}
{FB;01;66|64:TYP;SWV;BDN;PAC;KHR;PIN;KT0;DDY;KYR;KMT;DMT;KT0;RPL;UDC;IDC;IL1;UL1;TKK;TMI;THR;SYS|1AAD}
[1]+ Done netcat -l -p 12345
tobi@mordor:~/workspace/test$
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.29-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libcommoncpp2-dev depends on:
ii libccgnu2-1.7-0 1.7.3-1 A GNU package for creating portabl
ii libgcrypt11-dev [libgc 1.4.4-2 LGPL Crypto library - development
ii libgnutls-dev 2.6.6-1 the GNU TLS library - development
ii pkg-config 0.22-1 manage compile and link flags for
ii zlib1g-dev 1:1.2.3.3.dfsg-13 compression library - development
libcommoncpp2-dev recommends no packages.
Versions of packages libcommoncpp2-dev suggests:
ii libcommoncpp2-doc 1.7.3-1 Documentation files for Common C++
-- no debconf information
#include <string>
#include <iostream>
#include <cc++/socket.h>
#include <cc++/address.h>
using namespace std;
int main()
{
try {
// Testing TCP resending
string s;
string r;
s = "{FB;01;66|64:TYP;SWV;BDN;PAC;KHR;PIN;KT0;DDY;KYR;KMT;DMT;KT0;RPL;UDC;IDC;IL1;UL1;TKK;TMI;THR;SYS|1AAD}\n";
ost::IPV4Host host("127.0.0.1");
ost::TCPStream stream(host, 12345, 536, true, 3000);
// Send
stream << s;
stream.sync();
// SLEEP
sleep(3);
// if this line is commented out,
// two pacakges are sent as expected.
// however, if its commented in, only one packet is *sent*
// receive
try {
stream >> r;
}
catch (...)
{
}
sleep(3);
// send again
stream << s;
stream.sync();
sleep(3);
} catch (...) {
cerr << "TCP/IP Connection Error" << endl;
return false;
}
return 0;
}
#include <string>
#include <iostream>
#include <cc++/socket.h>
#include <cc++/address.h>
using namespace std;
int main()
{
try {
// Testing TCP resending
string s;
string r;
s = "{FB;01;66|64:TYP;SWV;BDN;PAC;KHR;PIN;KT0;DDY;KYR;KMT;DMT;KT0;RPL;UDC;IDC;IL1;UL1;TKK;TMI;THR;SYS|1AAD}\n";
ost::IPV4Host host("127.0.0.1");
ost::TCPStream stream(host, 12345, 536, true, 3000);
// Send
stream << s;
stream.sync();
// SLEEP
sleep(3);
// if this line is commented out,
// two pacakges are sent as expected.
// however, if its commented in, only one packet is *sent*
// receive
try {
//stream >> r;
}
catch (...)
{
}
sleep(3);
// send again
stream << s;
stream.sync();
sleep(3);
} catch (...) {
cerr << "TCP/IP Connection Error" << endl;
return false;
}
return 0;
}
--- End Message ---