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

SocketException question

Hello NG,

in my application I get a SocketException in my receive callback method, if
the remote socket closes.
What would be the right way to treat this exception?

I want to keep my socket working, so that I can continue to receive
messages from the remote application, as it comes back online.
My problem at the moment is, that if I call the udpClient.BeginReceive in
this moment, I again get the SocketException and from now on can't receive
any more messages on the socket.

Thanks for help and infos.

Regards
Rainer Queck
Jul 17 '08 #1
4 3298
On Jul 17, 4:50*pm, "Rainer Queck" <Rai...@noemail.noemailwrote:
Hello NG,

in my application I get a SocketException in my receive callback method, if
the remote socket closes.
Technically, a remote UDP socket cannot "close" from your perspective,
since there's no established connection channel as such.
What would be the right way to treat this exception?
Depends on what the exception is, really...what is
SocketException.ErrorCode for the one you get?
Jul 17 '08 #2
Hello Pavel,

"Pavel Minaev" <in****@gmail.comschrieb im Newsbeitrag
news:5da0f704-71dd-4fc2-833d-
>
Technically, a remote UDP socket cannot "close" from your perspective,
since there's no established connection channel as such.
>What would be the right way to treat this exception?
Depends on what the exception is, really...what is
SocketException.ErrorCode for the one you get?
<
The error code is 10054 and the message - translated from german - is:
"A existing connection was closed by the remote host"

Rainer
Jul 17 '08 #3
On Jul 17, 5:12*pm, "Rainer Queck" <Rai...@noemail.noemailwrote:
Hello Pavel,

"Pavel Minaev" <int...@gmail.comschrieb im Newsbeitrag
news:5da0f704-71dd-4fc2-833d-

Technically, a remote UDP socket cannot "close" from your perspective,
since there's no established connection channel as such.
What would be the right way to treat this exception?

Depends on what the exception is, really...what is
SocketException.ErrorCode for the one you get?
<
The error code is 10054 and the message - translated from german - is:
"A existing connection was closed by the remote host"
Hm... apparently, if you do a Send, and get the "ICMP port
unreachable" response, this manifests itself as an error on the next
Receive you try to do on the same socket. MSDN claims that a socket
is unusable once that happens, so you may have to recreate it entirely
on the same endpoint (once the client goes back online, it shouldn't
make any difference anyway, so long as the endpoint is the same).
Jul 17 '08 #4
Hello Pavel,

"Pavel Minaev" <in****@gmail.comschrieb im Newsbeitrag
news:0a**********************************@e39g2000 hsf.googlegroups.com...
>
Hm... apparently, if you do a Send, and get the "ICMP port
unreachable" response, this manifests itself as an error on the next
Receive you try to do on the same socket. MSDN claims that a socket
is unusable once that happens, so you may have to recreate it entirely
on the same endpoint (once the client goes back online, it shouldn't
make any difference anyway, so long as the endpoint is the same).
<
Basically I understand what you say, but...
If I start my app and send a udp message to a port which is not opened
(yet) I do get the socket exception (10054).
The confusing part is, that in this case I can call the
udpClient.BeginReceive within the Callback Method, without causing another
SocketException.

If a connection was establische, and then the remote socke closes I can't
call BeginRecieve without causing another (10054).
Why is that?

Regards
Rainer
Jul 17 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ShaneB | last post by:
Hello all! To test my app's exception handling, I've coded a call to DNS.BeginResolve() with an intentionally bad host name. When I put the code in a try/catch block, all works fine and a...
1
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to...
1
by: Frank | last post by:
I wonder if anyone could give me a suggestion on how to best handle this scenario. I wish to have an aspx page contact a server and receive messages. Initially, a login messge is sent, then...
1
by: Frank | last post by:
I wonder if anyone could give me a suggestion on how to best handle this scenario. I wish to have an aspx page contact a server and receive messages. Initially, a login messge is sent, then...
0
by: oferns | last post by:
Hi, apologies for the cluncky title.... Using WinXpSP2 & VS2005 Express editions..... I am writing an asynchronous socket client and I am getting a SocketException error on creating the...
6
by: Julien | last post by:
Hi, I am developing a C# application to send requests to mail server to check email addresses validity. I use a TcpClient object to connect to it with the Connect(String hostname, Int32 port)...
1
by: wesomon99 | last post by:
Hello, I have a JBoss web application (v4.04GA), run on an Apache Tomcat HTTP server (v5.5.17). It connects with a MySQL database (v4.1.10). My web application takes an XML file, creates a CSV file...
2
by: XenReborn | last post by:
Hi, I wrote a simple socket application, which connects to a simple socket server application I also wrote, the server opens a socket, listens, accepts connections, sends back a string of...
0
by: =?Utf-8?B?UmFqbmk=?= | last post by:
Dear William Stacey, I have written a server code using the Windows Socket API's. Wherein I have created the socket and bound it to a particular IP address and port number. Later I have made the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.