Broadcast information....

Mikirin
01-31-2002, 08:24 AM
Again, I have 4 'client' applications..

One will act as a data server... the other 3 will get data via XML string sent through winsock...

How can i get an application to do the following:

1: Broadcast (the clients will all be on machines with NO Static IP Address information) to see if one of the other clients (if any are running) have attained 'Server' status....

2: If none are running, set itself up as a server and answer any future 'broadcast queries' to tell the other clients that it has attained server status...

Idealy, i think, the client that attains server status will not be 'chatty' about its server status, it will just answer any queries.

e.g.

Client 1 starts and gets server status, because there are no other clients running. It determines this by sending a query out..
send (any servers out there)... None answer... Ok, Become a server.

Clients 2 - x startup, and send a query out... (any servers out there)... The server answeres (Yeah, I'm a server)..

The clients then communicate with the server application via direct IP...

I can get the local IP of the machines, and send this is a follow up message, (I'm a client, here is my IP address for you to send data to when i ask for some)

Help?

;-)

Thanks

ChiefRedBull
01-31-2002, 09:02 AM
Try setting your Winsock to UDP instead of TCP. UDP is connectionless, and is often used to 'broadcast' messages across networks.... just as you're doing here. You bind the control to a port, then send out the info you want, which will be directed to all the local machines with that port. The receiving machines will receive it just as an incoming TCP message.

Mikirin
01-31-2002, 09:06 AM
So sending via UDP wont require a 'destination' ip address?

ChiefRedBull
01-31-2002, 09:14 AM
No it wont. UDP (User Datagram Protocol) is a connectionless one. Brilliant. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum