Or do as I do.
The moment you received a connection request, check the ip against the other connections.
If that IP matches, write a value of '9'. Like this
Code:
socket = serverSocket.accept();
if(connections.contains(s.getInetAddress().getHostName())) {
for(int i = 0; i < 8; i++)
socket.getOutputStream().write(0);
socket.getOutputStream().write(9);
socket.close();
continue;
}
The reason this works is because the login process is setup.
Code:
stream.putByte(14);
stream.putByte(i);
socketStream.queueBytes(2, stream.buffer);
for(int j = 0; j < 8; j++)
socketStream.read();
int k = socketStream.read();
You can just ignore the stuff that the client writes, and skip directly to sending the first 8 bytes, (To be honest, I forgot what they're for. They're 'nulled' out in the Client though, so they're not assigned to any particular value.)
The 9th byte that's sent is the initial login response. Typically you would use a value of '0' to indicate that the login credentials should be sent next, but you can use any login response that denotes a 'failed' login attempt. So, by sending 9, the client takes it as a failed attempt response, and aborts the login attempt.