Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

How to unlock send function if ethernet link down

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.

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.