I have this application that has one sender, and multiple receivers,
the receivers are subscribing to a multicast group to which the sender
is sending information synchronously, while the receivers are receiving
asynchronously. My issue, is that if the if the receiver's socket
disconnects for any reason I want to be able to detect it and attempt
to reconnect.
Although I'm uncertain what to look for. I thought the receiver would
receive 0 bytes, but this is only with TCP. I would also like to
implement a time out where each attempt to reconnect is stalled for
that amount of time before trying to reconnect. Any help would be
appreciated. 5 2013
There is no such thing as a connection in UDP .. http://en.wikipedia.org/wiki/Connectionless_protocol
Not quite sure what you are looking for?
Cheers,
Greg Young
MVP - C# http://codebetter.com/blogs/gregyoun
"DaTurk" <mm******@hotma il.com> wrote in message
news:11******** **************@ f6g2000cwb.goog legroups.com... I have this application that has one sender, and multiple receivers, the receivers are subscribing to a multicast group to which the sender is sending information synchronously, while the receivers are receiving asynchronously. My issue, is that if the if the receiver's socket disconnects for any reason I want to be able to detect it and attempt to reconnect.
Although I'm uncertain what to look for. I thought the receiver would receive 0 bytes, but this is only with TCP. I would also like to implement a time out where each attempt to reconnect is stalled for that amount of time before trying to reconnect. Any help would be appreciated.
"DaTurk" <mm******@hotma il.com> wrote: I have this application that has one sender, and multiple receivers, the receivers are subscribing to a multicast group to which the sender is sending information synchronously, while the receivers are receiving asynchronously. My issue, is that if the if the receiver's socket disconnects for any reason I want to be able to detect it and attempt to reconnect.
Although I'm uncertain what to look for. I thought the receiver would receive 0 bytes, but this is only with TCP. I would also like to implement a time out where each attempt to reconnect is stalled for that amount of time before trying to reconnect. Any help would be appreciated.
You need to send keep-alive packets of some kind. UDP is connectionless,
so there is no "connection " to detect.
-- Barry
-- http://barrkel.blogspot.com/
Would it make sense then, since there esentially won't be any
disconnect, to just check for a SocketException , and assume that if we
catch one that the socket is unable to send receive, and attempt to
reconnect?
That's what I'm doing now, but I haven't tested it.
"DaTurk" <mm******@hotma il.com> wrote: Would it make sense then, since there esentially won't be any disconnect, to just check for a SocketException , and assume that if we catch one that the socket is unable to send receive, and attempt to reconnect?
UDP is unreliable and *connectionless *. It makes a best-effort to
deliver, but the packets may simply disappear into the ether. Any errors
you get may disappear with the next packet you send, but on the other
hand, the packets might simply have been dropped somewhere along the
way.
There is no "connection " process, so attempting to "reconnect" doesn't
actually do *anything*. That is, at the low level of the BSD socket API,
calling "connect" on a connectionless (i.e. UDP over IP) socket that you
already called "connect" on, does *absolutely* *nothing*.
The Windows API docs have this to say (connect function, Winsock):
---8<---
For a connectionless socket (for example, type SOCK_DGRAM), the
operation performed by connect is merely to establish a default
destination address that can be used on subsequent send/ WSASend and
recv/ WSARecv calls.
--->8---
There is no connection established when you call connect, and no bytes
leave your machine when you call connect.
If you *need* to know if the other application is listening, it either
has to echo your packets in some way, or send back a heartbeat of some
kind.
-- Barry
-- http://barrkel.blogspot.com/
Thanks for the reply, I think I didn't use the correct words, when I
say reconnect, I really mean set the socket up to receive
informationfrom the given multicast group
i.e. Bind, Subscribe to MultiCast Group, BeginReceive.
Like I said, I'm just expecting a Socket exception if it happens. Then
I attempt to go through the motions to put the socket back in a
position to receive information from the Multicast group. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Laxmikant Rashinkar |
last post by:
Is there any way to use a C# socket in promiscuous mode?
Any sample code that shows how this is done?
any assistance is much appreciated!
thanks
LK
|
by: Bernd |
last post by:
hi,
is it possible to use a Socket (proto_udp) and recieve icmp messages ?
what i want to do is, send a datagram to a remote host/port and check if
the host replies with port_unreachable (i think icmp type 3).
is this possible with a udp Socket and the RecieveFrom() method ?.
another approach would be (at least thats what i think) to use a raw
socket with proto_udp.
is this a wrong way to go ?
|
by: Gregory Hassett |
last post by:
I am writing a loop which will listen on a given port for incoming UDP
packets. If the UDP sender (client), terminates abnormally, then my call to
socket.BeginReceiveFrom throws a SocketException. I catch this exception,
then re-create the socket, and re-bind it. The next time I call
BeginReceiveFrom, I get that same exception again (" An existing connection
was forcibly closed by the remote host").
When writing a simple loop to listen...
|
by: BadOmen |
last post by:
Hi,
What is the different between 'System.Net.Sockets.Socket' and
'System.Net.Sockets.TcpClient'?
When do I use System.Net.Sockets.TcpClient and System.Net.Sockets.Socket??
Yours, Jonas
|
by: Adam Honek |
last post by:
Hello,
Can someone pinpoint me to a reliable link relating to sockets
and how they are implemented to allow client/server communication?
I'm finding quite a few but very few actually explain it step by step and
a lot of the source code examples I see is not commented or commented
poorly.
P.S Is Sockets and TCPClient the same thing?
| |
by: Dan Ritchie |
last post by:
I've got a client/server app that I used to send large amounts of data via
UDP to the client. We use it in various scenarios, one of which includes
rendering a media file on the client as it is transferred via the underlying
UDP transport. In this scenario it is very important to keep CPU usage as
low as possible.
Both the client and server were originally written in C++, but I've
re-written the client in C#, partly to simplify it, but...
|
by: J008 |
last post by:
Just looking for some insight as to why the callback "BeginReceiveFromCallback" is not being called in my "Receive" Subroutine below (when I call BeginReceiveFrom). I am trying to read data asynchronously using UDP. I have implemented Send and Connect subroutines in a similar way, and they both seem to work. When I put a breakpoint in the callbacks for Send and Connect, I hit them, and I can see the results I want. However, when I put a...
|
by: buc |
last post by:
Why does VB.NET UDP sockets send data on random ports?. If I set a simple
socket up to transmit a UDP packet on a port, look at the packet with a
sniffer, the actual packets source port and dest.port are diff. The packets
destination port is correct, but the packets source port it is actually sent
from is random. Why? How can I figure out the actual source port windows is
using, not what the vb.net socket is fake reporting?
Thanks BUC
|
by: 7stud |
last post by:
My question pertains to this example:
#!/usr/bin/env python
import socket, sys, time
host = sys.argv
textport = sys.argv
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |