Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

socket error

Posted on 2011-03-06
6
Medium Priority
?
569 Views
Last Modified: 2012-05-11
In my logs I see many "system error 104" during TCP send() which I am sure mostly likely connection was lost by server and serve is still trying to send the data.

However once in a while I do see "system error 32" also during send()
what could be the reason for sys error 32?  I am trying to chase an issue and just wanted to understand the socket behavior
0
Comment
Question by:learningunix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 35047062
Assuming that this is Linux, you can use perror to get a more human readable error message for these error codes.

You'll get something like "Connection reset by peer" for errno 104 (ECONNRESET), and "Broken pipe" for errno 32 (EPIPE).

In the context of a send, ECONNRESET means that the remote end (peer) closed the connection, sending a reset. And EPIPE means that the socket doesn't allow writing, or is not connected (both usually have local causes).
0
 

Author Comment

by:learningunix
ID: 35047882
Under what circumstance would socket not allow to write and fail with EPIPE?  is it because the socke is full? or something else?
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1600 total points
ID: 35048263
>> Under what circumstance would socket not allow to write and fail with EPIPE?

A common circumstance for this, is when the connection is in the process of being closed. The write half (sending half) can already be closed, but the read half (receiving half) not yet (waiting confirmation from the other end).

Read up on the TCP protocol for more specifics of how TCP connections are managed.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 400 total points
ID: 35051152
I've seen this happen before! First of all

32 maps to EPIPE - broken pipe

104 -  ECONNRESET connection reset by the peer

so if you are seeing this it is most definitely a case of closing either end of the socket before a send/recv has completed just as Infinity has suggested. The solution is to implement  a handshake so that the socket is not closed until you receive an acknowledgement about the receipt of the message from the other end.

Also see my solution in EE for a related problem
http://www.experts-exchange.com/Programming/Languages/CPP/Q_26557236.html
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 35053783
>> The solution is to implement  a handshake so that the socket is not closed until you receive an acknowledgement about the receipt of the message from the other end.

?? TCP already does that for you.
0
 

Author Closing Comment

by:learningunix
ID: 35060415
Thx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question