Broadcast TCP/IP message to several clients

V

vij21

Hello,

How could I send a broadcast TCP/IP message to all registered clients
at a server so that they begin to send any kind of data to server
sinchronously ?

best regards
 
R

Richard Maher

Hello back,

vij21 said:
Hello,

How could I send a broadcast TCP/IP message to all registered clients
at a server so that they begin to send any kind of data to server
sinchronously ?

Multicast would be good, but seeing as how the clients are "registered" how
about sending a UDP broadcast to a port of theirs that they've previously
told you about when they registered with the server on the TCP/IP
connection?
best regards

Cheers Richard Maher
 
V

vij21

Hello back,





Multicast would be good, but seeing as how the clients are "registered" how
about sending a UDP broadcast to a port of theirs that they've previously
told you about when they registered with the server on the TCP/IP
connection?




Cheers Richard Maher


Hello,

Assume that the server knows everything about clients (linked list
whith IP, Port, etc.) how do I generate an UDP Broadcast ? I read in
internet that in C# it works in the same way like unicast message only
broadcast IP should be entered, it is similar in Java ?

Or should I use java.net.DatagramSocket respectively
java.net.MulticastSocket ?

Thank you
 
R

Roedy Green

How could I send a broadcast TCP/IP message to all registered clients
at a server so that they begin to send any kind of data to server
sinchronously ?

You would need a socket connection to each client to use TCP/IP.
Broadcasting is done with packet level protocols.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"You can have quality software, or you can have pointer arithmetic; but you cannot have both at the same time."
~ Bertrand Meyer (born: 1950 age: 59) 1989, creator of design by contract and the Eiffel language.
 
K

Knute Johnson

vij21 said:
Hello,

Assume that the server knows everything about clients (linked list
whith IP, Port, etc.) how do I generate an UDP Broadcast ? I read in
internet that in C# it works in the same way like unicast message only
broadcast IP should be entered, it is similar in Java ?

Or should I use java.net.DatagramSocket respectively
java.net.MulticastSocket ?

Thank you

Just read the docs for MulticastSocket and it will show you how to make
it work. The only real difference from a DatagramSocket is that you
join the group you want to listen to, that is that you pick an IP
address and port (not necessarily your address) and open the socket.
Any broadcast to that IP and port will be caught.
 
M

markspace

vij21 said:
Assume that the server knows everything about clients (linked list
whith IP, Port, etc.) how do I generate an UDP Broadcast ? I read in
internet that in C# it works in the same way like unicast message only
broadcast IP should be entered, it is similar in Java ?

Or should I use java.net.DatagramSocket respectively

On the socket side, there's a setBroadcast(boolean) method. Set that to
true, I believe. I don't see anything similar for the datagram itself.
I guess you have to just know that 255.255.255.255 is IPv4 broadcast
and send to that address.

java.net.MulticastSocket ?

No. I'm 90% sure this is something else, don't use this. This is for a
server sending streaming data to multiple clients, and it requires
special network configuration. Most switches and gateways don't even
support it. Regular ol' broadcast is what you want, not multicast.
 
K

Knute Johnson

markspace said:
No. I'm 90% sure this is something else, don't use this. This is for a
server sending streaming data to multiple clients, and it requires
special network configuration. Most switches and gateways don't even
support it. Regular ol' broadcast is what you want, not multicast.

Reading the OP's original post, I think he wants to send a signal to all
of his clients to get them to start sending in data. Seems like the
perfect use of multicast to me.
 
M

markspace

Knute said:
Reading the OP's original post, I think he wants to send a signal to all
of his clients to get them to start sending in data. Seems like the
perfect use of multicast to me.


Excpet that, as I mentioned, almost nothing supports multicast, so the
packets will never reach their destination.

Multicasting is kind of an orphan in the TCP/IP spec. It was intended
to solve a problem no one really had, or wanted to solve. As far as I
know, it'll be like pulling teeth to get any network administrators to
configure their networks to support this, if it's even possible at all.
And if you have to go through an ISP or 3rd party network, forget it.

I could be all wrong, but I'd check with whoever is in charge of the
routers and gateways you'll have to go through before I wrote any lines
of code at all.
 
K

Knute Johnson

markspace said:
Excpet that, as I mentioned, almost nothing supports multicast, so the
packets will never reach their destination.

Multicasting is kind of an orphan in the TCP/IP spec. It was intended
to solve a problem no one really had, or wanted to solve. As far as I
know, it'll be like pulling teeth to get any network administrators to
configure their networks to support this, if it's even possible at all.
And if you have to go through an ISP or 3rd party network, forget it.

I could be all wrong, but I'd check with whoever is in charge of the
routers and gateways you'll have to go through before I wrote any lines
of code at all.

I agree if he has to cross any router boundaries he will have problems.
Inside a local network shouldn't be a problem.

UDP datagrams however can go anywhere. He could just send all of his
clients plain datagrams, a little more coding but not that tough.
 
E

EJP

vij21 said:
How could I send a broadcast TCP/IP message to all registered clients
at a server so that they begin to send any kind of data to server
sinchronously ?

Why exactly? Just have them start sending when they connect, and have
the server start reading all the connections when it is ready. The
clients will block once they've filled their socket send buffers until
the server starts reading.
 
V

vij21

Why exactly? Just have them start sending when they connect, and have
the server start reading all the connections when it is ready. The
clients will block once they've filled their socket send buffers until
the server starts reading.

Hello everyone,

An addition to my question:
What I should to do is to write a small project for the university. A
small Client/Server application with adjustable parameters that
measure the TCP/IP traffic depend on count of clients and bandwith. At
last it should show how the transmission time changes beacause of
collisions. Clients are all in the same domain/network and are
connected by a router.

For the best result clients should send data to the server (server
reading this data and measure the transmission time) sinchronously so
to start them all sinchronously I need a possibility to notify all at
once.

That's all.

Viktor
 
T

Tom Anderson

No. I'm 90% sure this is something else, don't use this. This is for a
server sending streaming data to multiple clients, and it requires special
network configuration. Most switches and gateways don't even support it.

This is absolutely true, but it's worth mentioning that it's irrelevant if
the participating hosts are all on the same subnet - then they can talk to
each other directly.

I think.
Regular ol' broadcast is what you want, not multicast.

Since broadcast is limited to the local subnet, anywhere that broadcast
works, multicast should work too.

tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top