Solved

socket error

Posted on 2011-03-06
6
553 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

746 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

12 Experts available now in Live!

Get 1:1 Help Now