- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 thisbytessend = send(conn.fd, ad, buffer_count, 0);
If ethernet is down , the bytessend should be -1, but it block forever. Thanks.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any suggestion is welcome, thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create a function say resetConn() and forcefully assign -1 to connection ID within this function...this willl reset your connection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page