Re: Socket Error?
- From: "Goran Sliskovic" <gsliskov@xxxxxxxxx>
- Date: Thu, 8 Dec 2005 11:37:09 +0100
<Buc> wrote in message news:%23wOmTO1%23FHA.2588@xxxxxxxxxxxxxxxxxxxxxxx
> I wrote a few lines of code to send a UDP packet to a remote machine. What
> worries me is the program code says it sends the data regardless of the
> remote IP or port. If the IP is ok , a sniffer verifies the packet was
sent.
> However, if I give the sendto statement a bogus IP or port (that is not
open
> on the remote machine), the code executes with no errors. I know UDP is
> connection-less, but the framework should balk at the bad or port (or at
> least it does in C or VB6). Any ideas how to get an error return? I used
to
> get a destination or port unreachable error in VB6, when I did a sendto
with
> a bogus IP or closed port. Heres the code:
> Lets say my network is 192.168.0.0..
....
Hi,
You should not count on sendto returning destination unreachable error when
host is unreachable. Only one special case exists when system can know that
host is unreachable and that is when local computer has no route to that
host. If you have default gataway or route to destination, you will never
get destination unreachable (sendto will return immediatly, buffering the
request to the OS). "Port unreachable" is not listed in error codes of
windows socket API. The only way you can tell that host is unreachable is by
time-out on host reply.
When using UDP, you must provide your own flow controll, error
detection/correction and retransmition. Plus be aware that UDP lacks
congestion controll, witch can have very unpleasant consequences on your
whole network if you are not aware of that.
Regards,
Goran
.
- References:
- Socket Error?
- From: Buc
- Socket Error?
- Prev by Date: Re: Sharing Config File Between Processes
- Next by Date: RE: Verifiable .exe impossible using managed C++?
- Previous by thread: Socket Error?
- Next by thread: Memory leak with socket BeginReceive?
- Index(es):
Relevant Pages
|