Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

Setting a LWIP Non Blocking Socket

Altera_Forum
Honored Contributor II
1,763 Views

Hi, 

 

Has anyone come a cross an issue with setting a non-blocking socket in LWIP. 

 

I did the following: 

 

if ((pNetworkManager->fd_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) 

die_with_error("CreateSocketTask: Socket creation failed"); 

 

u32_t on = 1; 

 

if (lwip_ioctl(pNetworkManager->fd_socket, FIONBIO, &on)) 

close(pNetworkManager->fd_socket); 

 

... 

 

which appears to be supported by LWIP but my socking is still blocking. 

 

Any ideas or thoughts would be greatly appreciated.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
945 Views

I am not sure if you can create a socket that is non-blocking per se (I am not a sockets expert), but I do know you can to send() and recv() non-blocking; the data is just posted to the stack and gets sent later, or in the case of recv(), you get back an error if nothing (or less than your desired number of bytes) was received. 

 

Check out the web_server example design, http.c, and look at how sends and receives are done. This example shows non-blocking I/O so that multiple web clients can be served at the same time.
0 Kudos
Reply