Question

I created a Java networking program and every once in a while when I run (it doesn't happen all the time) it I get a ghost number, my sockets receive a number something like -16956754 (its always the same number) and I never send though the sockets a number anywhere close to the number I am receiving. Could it be because I'm getting traffic on the port I am using? I'm using 25565 which is a pretty common port..

If so which port do you recommend to be the least used that will fit a game application?

Was it helpful?

Solution 2

Solved by changing the port to a non used port.

OTHER TIPS

Any network server socket (like your application) opens a socket (with a port), and waits for connections. The socket has no idea where the connection is coming from, and what the client side of the socket is going to do. Whatever the application, there will always be the chance that a client connecting to the server is not the one you are expecting.

In your program you need to create a protocol that identifies the client to the server as the type of client you expect. If the client is not the right application, then you should drop the connection.

For example, the Mail protocol expects the client to send an EHLO or HELO prompt, HTTP expects a GET, POST, or PUT, etc.

In your case, you may have chosen a port that's used by Minecraft, but that is no reason to stop using that port, if you can identify the client types that are important to you.

Setting up a server and expecting the only thing to connect to be valid clients is not reasonable.

Changing ports will only make the problem less frequent (maybe), and not make the problem go away.

If it is your own application and want to choose a port, you would choose something that is no t a 'pretty common port' . In this case it looks like a port used by Minecraft server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top