LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2014, 05:28 PM   #1
5883
Member
 
Registered: Aug 2004
Posts: 173

Rep: Reputation: 0
socket code returns 103 and 107 sometimes


10% of the time, my socket code in the linux board says 103 and 107.
Most of the time it works.
This board is running ubuntu 12.04, 2 ethernet port managed by NetworkManager.

Socket Connect Error 103 at Connect().

To reproduce it, just reboot the board 10 times, you'll see it happen once. No need to remove the cable etc.

At the same time, ping on both ports are still working.

What could be the cause pls ?

Thanks !
 
Old 03-01-2014, 10:09 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,432

Rep: Reputation: 669Reputation: 669Reputation: 669Reputation: 669Reputation: 669Reputation: 669
if you mean 'errno' then use 'strerror', or grep in /usr/include/asm-generic/errno.h
 
Old 04-06-2014, 10:37 PM   #3
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
someone mentioned this, any comments pls ?

Errno 107 means that the socket is NOT connected (any more). There are several reasons why this could happen. Assuming you're right and both sides of the connection claim that the socket is still open, an intermediate router/switch may have dropped the connection due to a timeout. The safest way to avoid such things from happen is to periodically send a 'health' or 'keep-alive' message. (Thus the intermediate router/switch accepts the connection as living...)=

how do i do this keep-alive ?


Quote:
Originally Posted by NevemTeve View Post
if you mean 'errno' then use 'strerror', or grep in /usr/include/asm-generic/errno.h
 
Old 04-07-2014, 12:26 PM   #4
rtmistler
Senior Member
 
Registered: Mar 2011
Location: Milford, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 2,334
Blog Entries: 9

Rep: Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792
So, ping is IGMP and does not create a connection to communicate like a protocol using sockets. Therefore it merely means that the IP stacks are working on both sides and that there's a capability to communicate still available.

This socket is probably from some service or application; the question becomes what app or service is using the socket. There's a keep alive attribute, SO_KEEPALIVE which can be applied if you're the one controlling the socket calls. In a SOCK_STREAM I believe that there is also a condition where if one side transmits and it times out (TCP does not receive an ACK - because it is a connection-oriented, reliable protocol) then the original transmitter determines that the socket is unavailable. Therefore if the remote side shut down it's service or application, thus closing the socket on their side, it would lead to a potential error, or not really error but report on your side saying things like what you're seeing.

To answer your question about how to use the keepalives, I pretty much always have to look it up, so I did and this one seems reasonable, there's a whole document, this link points to the section where there's a code example. There are however instructions for command line options if you're establishing a socket from outside a program. TCP Keepalive HOWTO.

Last edited by rtmistler; 04-07-2014 at 12:28 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
K3B - cdrecord returns unknown error (code 22) AlanSecker Linux - Software 2 07-11-2014 08:34 PM
getsockopt returns 111 as error code when invoked after epoll_wait call msubrahmanya Linux - Kernel 0 09-06-2012 06:38 AM
[SOLVED] cURL POST data command from shell returns HTTP Error Code 408 fyndr Linux - Software 3 03-04-2011 09:17 AM
[SOLVED] bind() returns EINVAL with PF_INET socket hda7 Linux - Networking 2 04-12-2010 12:09 PM
HTTPS returns error code -12263 mesh2005 Linux - Server 3 07-10-2007 11:52 AM


All times are GMT -5. The time now is 04:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration