lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Nonblocking sockets problem


From: Åke Forslund
Subject: Re: [lwip-users] Nonblocking sockets problem
Date: Wed, 14 Mar 2012 10:17:46 +0000

I see my mistake there, however even with code that is at least theoretically 
sane I can't establish a connection. lwip_accept() always returns EWOULDBLOCK 
for me.

from socket debug:
lwip_accept(0)...
lwip_accept(0): returning EWOULDBLOCK
[Repeats forever]

putty reports "Connection closed by remote host" followed by "Network error: 
Software caused connection abort" or "Connection reset by Peer"

So it seems I've made some mistake elsewhere as well. Maybe Putty isn't the 
best tool to test this and I have to write some simple socket-script/program to 
check this thoroughly. I'll go back and check API_EVENT() macro as well and try 
to wrap my head around what is supposed to happen.

Thanks for all the help
/Åke

-----Ursprungligt meddelande-----
Från: address@hidden [mailto:address@hidden För Simon Goldschmidt
Skickat: den 14 mars 2012 10:00
Till: Mailing list for lwIP users
Ämne: Re: [lwip-users] Nonblocking sockets problem

"Åke Forslund" <address@hidden> wrote:
> Hi again, this is not the original code but a implementation of the 
> problem in our simple telnet-server for debug. Code below. In our 
> original code we use ioctlsocket() to set non-blocking but using lwip_ 
> fcntl() makes no difference.

The code you sent works for me with one slight modification: you have to check 
the return value of lwip_accept() to be >= 0 to enter the first while(1) loop. 
Better yet, use select to see if accept will succeed (put lSocketRecv on the 
readset).

You don't check the return value of lwip_accept() although calling it on a 
nonblocking socket: unless there's actually a new connection pending -1 will be 
returned. Then of course, the inner while(1) loop is never exited because you 
will never receive 'q' without a client (lwip_read() always returns -1 as 
new_fd is -1).

Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis 
zu 50,- Euro! https://freundschaftswerbung.gmx.de

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

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