I am still learning Java, but I had done it in C using socket. For Lan game,
I assume
that the program has both server and client. I am using multicast socket for
advertizing
the server on the Lan with a specific message(IP address and port for
Unicast); Before
starting the Multicast, the server has already started using Unicast socket.
The broadcast
message is sent every second or so. Once the client receives the broadcast
message,
it can use the IP and port to connect to the server. However, I had not
tried Multicast
only for actyual playing the game since every single message sent to
Multicast socket
will be recieved by other computer without loosing a bit. Since there is a
limited number of sockets
is allowed, using Multicast socket will allow more participants for the
game. The drawback
for this Multicast socket is that the computers outside the Lan can not
play.
"Ian Shef" <in*****@avoidi ng.spamwrote in message
news:Xn******** *************** *****@138.126.2 54.210...
"Brian Odsgaard" <ma**@oddball.r emove.dkwrote in news:4907b56b$0 $15899
$e*******@dtext 01.news.tele.dk :
>Hi all
I'm going to build a simple multiplayer game.
The task is to create a game that runs on multiple computers on a LAN.
I want to create a solution that don't need a server running on a
specific
computer with a specific IP - all computers should be able to initiate a
game and act as server.
How can I make an application search the LAN to find if any connected
computers is running as server - without knowing the IP on the other
computers?
- Brian
My guess is that you would perform a broadcast to all addresses on the
LAN,
with a destination of a specific port # and with a specific known message
content.
Eligible servers would respond with some other known message.
You may get many responses, a single response, or no responses. You will
have to set a time limit on when the response can occur.
You may want to perform some additional negotation with or authentication
of
the responding computers.
I haven't actually tried this, and I am interested in what others suggest
or
have done.