setsockopt and SO_RCV/SNDTIMEO

Lefteris Tsintjelis lefty at ene.asda.gr
Thu Oct 6 15:23:41 PDT 2005


Hi,

I am trying to set something like this up but it doesn't seem to work
as I expect it (unless I expect wrong):

timeout.tv_sec = 4;
timeout.tv_usec = 0;
if(setsockopt(listenSocket, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, sizeof(timeout)) == -1)
	fprintf(stdout, "setsockopt SO_RCVTIMEO failed: %s\n", strerror(errno));
if(setsockopt(listenSocket, SOL_SOCKET, SO_SNDTIMEO, (void *)&timeout, sizeof(timeout)) == -1)
	fprintf(stdout, "setsockopt SO_SNDTIMEO failed: %s\n", strerror(errno));

When I telnet to the socket, the socket always stays connected. The
timer doesn't seem to work right. Am I missing anything here or is
this broken?

Please CC

Thnx,

Lefteris


More information about the freebsd-stable mailing list