Can anyone confirm that socket receive timeout is supported?

davepl
Posts: 29
Joined: Wed Jun 27, 2018 5:29 pm

Can anyone confirm that socket receive timeout is supported?

Postby davepl » 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.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Mon Nov 12, 2018 6:15 pm

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.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Majestic-12 [Bot] and 86 guests