sockets.h defines 3 socket protocol types: SOCK_STREAM, SOCK_DGRAM and SOCK_RAW.
Do any of these support blocking reads?
I am using the lwip_socket(..) function to create the socket and lwip_read(..) or lwip_recv(..) to do the reads.
Underneath both read functions ultimately call: lwip_recvfrom(..).
I see that lwip_recv(..) allows for some flags to be passed in while the lwip_read(..) does not. Are there specific flags to enable blocking read?
Is there a way to specify you want blocking reads when configuring the socket/connection?
Is there some way to achieve the blocking read via the lwip_setsockopt(..) function?
I am specifically using SOCK_STREAM in specific tests and can't get the read() to block. I am interested all 3 socket protocol types as mentioned previously.
I have looked at the sockets.h/sockets.c code but it's not obvious what the default behaviors are and how to achieve the blocking read semantic.
Which socket protocol types support blocking read? stream? dgram? raw?
Re: Which socket protocol types support blocking read? stream? dgram? raw?
setsockopt(..) can be used to control the send and receive timeouts. It appears the connect timeout is not currently supported
I have tried/verified both send and receive timeouts do indeed work as expected for at least socket protocol type: SOCK_STREAM
Code: Select all
#include "sockets.h"
struct timeval tv;
tv.tv_sec = 10 ; // seconds
tv.tv_usec = 0 ;
int rc = setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
Who is online
Users browsing this forum: Google Adsense [Bot] and 68 guests