Probably 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@gnu.org > http://lists.gnu.org/mailman/listinfo/bug-commoncpp
<<attachment: dyfet.vcf>>
_______________________________________________ Bug-commoncpp mailing list Bug-commoncpp@gnu.org http://lists.gnu.org/mailman/listinfo/bug-commoncpp