Re: Winsock1 broadcast question?
- From: "expvb" <nobody@xxxxxxx>
- Date: Mon, 16 Oct 2006 13:19:07 -0400
"Andrew" <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:44080E2E-1767-4EBD-9E51-97EDEEAFEB8F@xxxxxxxxxxxxxxxx
What I would like to do is, I have a server that I wanted to broadcast
information over the network, and have about 5 clients listening on a
specified port. They all receive the information and process it what ever
why
I want it to. I can do this on a single point to point connection, but I
don't know how to do this with multiple computers.
How can I broadcast information to multiple computers at once?
I have tried some code from the net, but can't seem to get it to work.
Any body have any ideas?
Before you can send broadcasts, you must enable SO_BROADCAST on the UDP
socket. See MSKB Q237688. To send a broadcast, set RemotePort to whatever
the other side is using, and set RemotHost to "255.255.255.255", and send.
Also, it's best to make the server listen on a specific port, such as 5555,
but don't make the client listen on specific ports, let them use a dynamic
port. This can be done by setting LocalPort to 0 before the first Send. If
you use specific ports for the clients, you will run into problems with
firewalls, especially with clients connecting over the Internet. When each
client starts up, it should send a dummy packet to the well known port of
the server, so the server knows which port the client is using and send to
that particular IP and port. The server can tell the port used by the client
by checking RemotePort property in DataArrival event. This way only the
server needs to listen to a well known port.
If you want the client to listen to a well known port, then that's your
choice. It will certainly work fine in a LAN except when the clients are
running XP+SP2, which introduced Windows Firewall and it blocks the ports by
default, so you have to open them on clients and server. If the clients used
a dynamic ports, then you only need to open the port at the server, so it's
less of a headache.
Also, if the client is behind a router, such as those using the Internet
with common routers like Linksys routers, then you have to open the port as
well in the router, but this is not required when you use dynamic ports.
Good Luck!
.
- Prev by Date: Re: IDispatch Interface
- Next by Date: Re: Detecting debug mode
- Previous by thread: Added Form gives Error during load
- Next by thread: Re: vb6 callstack without error?
- Index(es):
Relevant Pages
|