473,386 Members | 1,610 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,386 software developers and data experts.

An existing connection was forcibly closed by the remote host

4
Hello EveryOne!

I am working on TCP socket programmming Client/Server. I am using asynchronous methods.What it does - I have a server Application which can accept more then 5 client at the same time. After stablishing the connection to the server I start reveving data from client using Begin Recive, when i forcefully disconnect one of my client i get a error "An existing connection was forcibly closed by the remote host ". I want to know is their any method to solve this issue.

Expand|Select|Wrap|Line Numbers
  1. void ReceiveData(IAsyncResult iar)
  2. {
  3.    try
  4.    {
  5.       Socket client = (Socket)iar.AsyncState;
  6.       int recv = client.EndReceive(iar);
  7.       if (recv == 0)
  8.       {
  9.          conStatus.Text = "Client" + client.RemoteEndPoint.ToString() + " has disconnected.";
  10.          server.BeginAccept(new AsyncCallback(AcceptConn), server);
  11.          return;
  12.    }
  13.    string receivedData = Encoding.ASCII.GetString(data, 0, recv);
  14.    results.Items.Add(receivedData + client.RemoteEndPoint);
  15. }
  16.  
Jan 30 '08 #1
3 2962
Plater
7,872 Expert 4TB
You could finish your try/catch block by having a catch for it then ignoring it?
The error comes when you try to do a read/write operation on a socket that has been closed.
Feb 4 '08 #2
imoon
4
You could finish your try/catch block by having a catch for it then ignoring it?
The error comes when you try to do a read/write operation on a socket that has been closed.

Thank for reply ............. but I want a proper soultion b/c i want to show message box to server which client is disconnect.
Feb 14 '08 #3
Plater
7,872 Expert 4TB
Well try/catch would be a pretty proper solution in this case....

But you could always Poll() for connectivity and see when it disconnects.
Feb 14 '08 #4

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

Similar topics

0
by: Mike | last post by:
VB .NET 2003, Pocket PC 2003, CF 1.0 SP 2 Only when I use a proxy server, I'm getting this error when attempting to write data to a Stream object from an HTTPWebRequest object....
26
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On...
0
by: SisAndz | last post by:
Hello, I'm trying to do a secure connect to the site https://212.77.100.18/p/ with ..net 2.0 HttpWebRequest class, unfortunately for some reason I'm not able to do that - WebException is thrown...
0
by: Sanjay T | last post by:
Hi, We are using ASP.Net 2005 and SQL Server 2005. We are storing sessions in the database. From time to time we get the following exception in the application while the ASP.Net session tries...
1
by: balaya | last post by:
was an error downloading 'https://pushmxtest.equitynational.com/EquityNational/PushMXService.svc/secure'. The underlying connection was closed: An unexpected error occurred on a receive. Unable...
4
by: Anbu | last post by:
Hi All, I'm using the Cassini component in my desktop application to create a web site to host the web services. The application works fine in normal scenario. If the system is kept idle for...
1
by: Jim Hubbard | last post by:
We are using a .Net 2.0 app that connects to a SQL 2005 Express DB and we keep getting this message on the clients. Has anyone seen this error or a solution to it?
1
by: rhepsi | last post by:
hii all, When im trying to upload all the resized photos from the local server onto the live ftp server, im getting an error stating tht: "An existing connection was forcibly closed by the...
2
by: OrcaDK | last post by:
Hi I've started receiving sporadic SqlExceptions throughout my .NET applications (crossing ASP.NET, Windows Services, Winforms - doesn't seem application code specific):...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.