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++
12618 Discussions

How to unlock send function if ethernet link down

Altera_Forum
Honored Contributor II
1,093 Views

I send some data by TCP use nichestack. When the ethernet link down , the send function block forever, so all the task is dead. 

 

How to resolve this problem? 

 

The code is like this 

bytessend = send(conn.fd, ad, buffer_count, 0);If ethernet is down , the bytessend should be -1, but it block forever. 

 

Thanks.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
399 Views

Any suggestion is welcome, thanks a lot

0 Kudos
Altera_Forum
Honored Contributor II
399 Views

Create a function say resetConn() and forcefully assign -1 to connection ID within this function...this willl reset your connection

0 Kudos
Altera_Forum
Honored Contributor II
399 Views

kaushal,thanks for your replay 

I know what you say , but my questions is how to detect the link is down. 

The programme block at send() function and don't return.  

I want return from the send function when link is down and then reset the connection.
0 Kudos
Altera_Forum
Honored Contributor II
399 Views

I think that normally send() would return if the link goes down. At least this is what happens in my system; but maybe the behaviour is related to the mac-phy you are using. 

Alternatively you can configure the socket in non blocking mode. In this way send() always returns and then you can test the link and decide if you want call send() again or reset the connection.
0 Kudos
Reply