Solved

socket error

Posted on 2011-03-06
6
556 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
  • 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 400 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 12

Assisted Solution

by:trinitrotoluene
trinitrotoluene earned 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

816 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now