Solved

socket error

Posted on 2011-03-06
6
558 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 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
Technology Partners: 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 73
Task manager indicates my c++ program memory consumption is growing? 12 165
Problem with SqlConnection 4 193
Issues with C++ Class 19 120
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

751 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