|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
TCPtream bughi,
I recently found TCPStream bug when performing TCPStream::open(). here is my code: TCPStream client; client.setTimeout(5000); //this will let connect() function be non-block while(1) { client.connect(IPV4Host, port, buffer); if(!client.isConnected()) { ::usleep(1000000*3); continue; } } Once the first run in connect() failed, it will keep connecting to indicated IP and port but the 2nd time it connect, will cause the socket error (I print out the errno) I found the socket do not re-initialize when connect() failed. if add the code in line 3125 so = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); it will work well _______________________________________________ Bug-commoncpp mailing list Bug-commoncpp@... http://lists.gnu.org/mailman/listinfo/bug-commoncpp |
|
|
Re: TCPtream bugProbably instead, connect methods should actually do this if the so is
invalid when they are called. If we do fail to connect, we should release the resource as we do now. If we decide to close/delete the object on a connect failure, then we would not be waisting resources acquiring a brand new socket we may never use. Part of this is also tied to the use of connect as a constructor method, where the object is then in a clean state with no socket held if the connect failed at initialization. But either way, I will look at resolving this for the next release. Vincent Chen wrote: > hi, > > I recently found TCPStream bug when performing TCPStream::open(). > here is my code: > > TCPStream client; > client.setTimeout(5000); //this will let connect() function be non-block > while(1) > { > client.connect(IPV4Host, port, buffer); > if(!client.isConnected()) > { > ::usleep(1000000*3); > continue; > } > } > > Once the first run in connect() failed, it will keep connecting to > indicated IP and port > but the 2nd time it connect, will cause the socket error (I print out > the errno) > > I found the socket do not re-initialize when connect() failed. > if add the code in line 3125 > > so = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); > > it will work well > > > ------------------------------------------------------------------------ > > _______________________________________________ > Bug-commoncpp mailing list > Bug-commoncpp@... > http://lists.gnu.org/mailman/listinfo/bug-commoncpp [dyfet.vcf] begin:vcard fn:David Sugar n:Sugar;David org:GNU Telephony email;internet:dyfet@... tel;work:+1 609 465 5336 url:http://www.gnutelephony.org version:2.1 end:vcard _______________________________________________ Bug-commoncpp mailing list Bug-commoncpp@... http://lists.gnu.org/mailman/listinfo/bug-commoncpp |
| Free embeddable forum powered by Nabble | Forum Help |