lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] lwip_accept() blocks for non-blocking sockets ?


From: Tamas Somogyi
Subject: [lwip-users] lwip_accept() blocks for non-blocking sockets ?
Date: Tue, 30 Sep 2008 17:35:36 +0100

Hi,

It seems that lwip_accept() blocks the calling thread even if the
listening socket is set to non-blocking mode - see sample code below.
Is it the normal behaviour or a bug?
Winsock's accept() returns immediately for non-blocking sockets...
As far as I debugged, it seems that sys_[arch_]mbox_fetch() waits
forever or till the first connection.
I'm using the Win32-port of LwIP 1.3.0, but this bug perhaps comes on
other platforms as well. Maybe using sys_mbox_TRY_fetch would be more
appropriate if FIONBIO is set, however I'm not familiar with using
mailboxes in lwIP, therefore I would not dive deeper in the code if
somebody can quickly tell me the right solution.

Thanks,
Tamas Somogyi



Example code:
//create socket
int s = lwip_socket(PF_INET, SOCK_STREAM, 0);

//set to non-blocking mode
int i = 1;
lwip_ioctl(s, FIONBIO, &i);

//listen
lwip_listen(s, 0);

//accept connection
struct sockaddr addr;
socklen_t l;
int t = lwip_accept(s, &addr, &l); //lwip_accept doesn't return until an
incoming connection happens




reply via email to

[Prev in Thread] Current Thread [Next in Thread]