Page 1 of 1

Can anyone confirm that socket receive timeout is supported?

Posted: Mon Nov 12, 2018 5:29 pm
by davepl
I'm setting a socket read timeout but still seeing it (I think) hang in read().

Code: Select all

        
        struct timeval to;
        
        
        to.tv_sec = 3;
        to.tv_usec = 0;
        
        if (setsockopt(new_socket,SOL_SOCKET,SO_RCVTIMEO,&to,sizeof(to)) < 0)
        
        {
        
            Serial.printf("Unable to set read timeout on socket!");
            
            return false;
            
        }
Does anyone know, or can anyone confirm, that it's actually supported correctly? My assumption/expectation is that if I ask for 1024 bytes and, let's say, 703 come in and then nothing further, that it'll time out after 3 seconds. But it doesn't seem to, at least not reliably.

Re: Can anyone confirm that socket receive timeout is supported?

Posted: Mon Nov 12, 2018 6:15 pm
by Ritesh
davepl wrote:
Mon Nov 12, 2018 5:29 pm
I'm setting a socket read timeout but still seeing it (I think) hang in read().

Code: Select all

        
        struct timeval to;
        
        
        to.tv_sec = 3;
        to.tv_usec = 0;
        
        if (setsockopt(new_socket,SOL_SOCKET,SO_RCVTIMEO,&to,sizeof(to)) < 0)
        
        {
        
            Serial.printf("Unable to set read timeout on socket!");
            
            return false;
            
        }
Does anyone know, or can anyone confirm, that it's actually supported correctly? My assumption/expectation is that if I ask for 1024 bytes and, let's say, 703 come in and then nothing further, that it'll time out after 3 seconds. But it doesn't seem to, at least not reliably.
Yes. We have euses while reading data from http server using socket for firmware download and we are able to use socket receive timeout successfully without any issue.