Question

I'm working on a server for the game Minecraft, which shows a dark-red screen when the player is disconnected. I'm disconnecting players like this:

Socket.Shutdown( SocketShutdown.Both );
Socket.Close();

I seem to be unable to write data after that, but the disconnected screen doesn't appear. It only appears when I completely terminate the server application, which indicates that the connection isn't closed at all.

What am I doing wrong?

Edit:

socket.BeginAccept( new AsyncCallback( AcceptClient ), null );

private void AcceptClient( IAsyncResult result )
    {
        try
        {
            // Initialize player
            Socket client = _socket.EndAccept( result );

.

Log( "Received unrecognized packet from " + player.IPAddress() + ", disconnecting client!" );

player.Disconnect();
_clients.Remove( player );
Was it helpful?

Solution

I don't know what the API looks like for Minecraft, but odds are that there's a command you need to send to the client first, to let them know they've been disconnected.

OTHER TIPS

What about Socket.Disconnect() ?

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