PulsePanda
PulsePanda

Reputation: 1856

How to have a Server Socket broadcast that it's there, and have a client socket detect it and connect

I think we've all played Minecraft before, and know that it can have a local server detection. A lot of games do it, where one player hosts a game, and another can connect just because it's on the same network. I'm wondering, how would you code something like this in java? How does a server on minecraft broadcast itself to the network, and how does the client find and connect to it? If this is the wrong place to put this, i'm sorry I didn't know, but I feel it might be.

How do you have a socket broadcast that it's there and connectable, and have another socket find and connect to it, the same way a lan game works?

Upvotes: 1

Views: 589

Answers (1)

CuriousMind
CuriousMind

Reputation: 3173

@PulsePanda, the logic can be implemented using Multicasting. Using this protocol you can broadcast a message to machines in a LAN. Another example of this implementation is IPMsg. You can find more information about multicast here. JDK 7 comes with built-in multicast socket. You can also find detailed example at following location.

Upvotes: 1

Related Questions