B
Brandon
I am trying to use a UDP broadcast in C# to basically publish a stream of
data to any number of processes running on the local machine that care to
listen in - and I do not want this broadcast getting off of the machine onto
the network. It should be noted that I test on the full framework first,
because of the higher visibility and simpler IP routing situation. At first
this question may not sound like it belongs on this particular board, but
bear with me - some of this is just background to answer questions that I
know will be asked:
My first thought was to broadcast to 127.0.0.1, and this works fine except
that it seems that only one process can listen at a time... process A will
be receiving the stream, and as soon as process B binds, process B starts
receiving the stream and process A is just blocking, then as soon as process
B unbinds, process A picks up the stream again. And I am using
Socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, true);
So the next thing I tried was to broadcast to 255.255.255.255 with a
Socket.Ttl of 0. This works exactly how I want it to - both process A and B
running local receive the stream of data simultaneously, while process C
which was running on a different machine on the same ethernet segement did
not. Unfortunately, when I went to port this over to the compact framework
(2.0), I found that Socket.Ttl does not exist... How do you set the TTL on
the compact framework? On the full framework, I tried
Socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.IpTimeToLive, 0), which is available on the compact
framework, but it did not keep the broadcast off of the network (process C
running on a different box on the same ethernet segment received the
broadcast).
Thanks in advance for any tips you might have.
data to any number of processes running on the local machine that care to
listen in - and I do not want this broadcast getting off of the machine onto
the network. It should be noted that I test on the full framework first,
because of the higher visibility and simpler IP routing situation. At first
this question may not sound like it belongs on this particular board, but
bear with me - some of this is just background to answer questions that I
know will be asked:
My first thought was to broadcast to 127.0.0.1, and this works fine except
that it seems that only one process can listen at a time... process A will
be receiving the stream, and as soon as process B binds, process B starts
receiving the stream and process A is just blocking, then as soon as process
B unbinds, process A picks up the stream again. And I am using
Socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, true);
So the next thing I tried was to broadcast to 255.255.255.255 with a
Socket.Ttl of 0. This works exactly how I want it to - both process A and B
running local receive the stream of data simultaneously, while process C
which was running on a different machine on the same ethernet segement did
not. Unfortunately, when I went to port this over to the compact framework
(2.0), I found that Socket.Ttl does not exist... How do you set the TTL on
the compact framework? On the full framework, I tried
Socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.IpTimeToLive, 0), which is available on the compact
framework, but it did not keep the broadcast off of the network (process C
running on a different box on the same ethernet segment received the
broadcast).
Thanks in advance for any tips you might have.