473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to handle socket error connection reset

11
We have socketserver that was developed using SocketAyncEventArgs based loosely on based loosely on the MS sample at http://msdn.microsoft.com/en-us/libr...eventargs.aspx

Recently we had an issue with the socket server , it is not accepting new connections at all.But after restarting the service it worked.It is happenning frequently.

When I looked into the logs , I see lot of connection reset error on connecting it self.

Code is something like below
Expand|Select|Wrap|Line Numbers
  1.   private void ProcessAccept(SocketAsyncEventArgs e)
  2.   {
  3.         try
  4.         {
  5.            if (e.SocketError == SocketError.Success)
  6.            {
  7.  
  8.               code to read message from client.
  9.  
  10.            }else
  11.            {
  12.                 if (e.SocketError != SocketError.OperationAborted)
  13.                             log.WarnFormat("Unexpected SocketError in ProcessAccept: {0},{1}",IP, e.SocketError.ToString());
  14.            }
  15.      }
  16.      catch (Exception ex)
  17.      {
  18.           log.ErrorFormat("Exception in ProcessAccept: {0}",ex.Message);
  19.      }
  20.      try
  21.      {
  22.                     // Accept the next connection request
  23.               StartAccept(e);
  24.      }
  25.      catch (Exception ex)
  26.      {
  27.            log.Fatal("Could not listen for new connection", ex);
  28.      }
  29.  

I get connectionreset message in else statement.
My question is Do I need to close the socket in else statement , that returns SocketErros ? like e.AcceptSocket.Close() ;?How should I hanlde the connectionreset errors in this case?
Jan 16 '13 #1
0 1802

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Tim Clacy | last post by:
Please illuminate; what operator of class 'Event' will get matched for these two cases : Event ev1; Event ev2; // Case 1 // if (ev1) ;
7
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have...
0
by: Tony Johansson | last post by:
Hello! Here I have two classes these are called Handle and Body and a main. You have the class definition below. Some basic information. In the Handle class is there a pointer to the Body. Each...
2
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to...
14
by: Howard | last post by:
Hi, I recently had a problem where I decided to store objects in a vector. (Previously, I had always stored pointers in vectors). Well, naturally, when storing an object in a vector, using...
6
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in...
7
by: Ken Varn | last post by:
I am working in managed C++. I have a Mutex object in which I need to replace the Handle property with a new handle. The new handle is being constructed using Win32 CreateMutex call. I need to...
13
by: Abhishek | last post by:
Hi, how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application only even if there is any other window in front of it. I dont...
2
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
3
by: dav006mex | last post by:
I have almost no experience with Network programming on C#. I have an Asynchronous UDP socket on a server that sends data to clients. If one of the client crashes i get the next Socket Error: ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.