I'm trying to make an rpg game. Im setting up the client and server, but now i have a problem: the server can't accept more then 1 connection, then it says the server is offline. Also, after you closed the first connection, you can't re-connect to the server.
Can someone please tell me what is wrong so i can change my source code?
the project is below
thanks in advanced,
jimpie
Last edited by jimpie; Jul 15th, 2011 at 03:00 AM.
Reason: solved
Just change the AcceptConnection() function in your modDatabase to this:
Code:
Public Sub AcceptConnection(ByVal RequestID As Long)
Dim i As Long
i = FindOpenPlayerSlot
If i <> 0 Then
' we can connect them
frmServer.Socket(i).Close
frmServer.Socket(i).Accept RequestID
Call SocketConnected(i)
End If
End Sub
And in your socket_ConnectionRequest() on the frmServer, make it like this:
Code:
Private Sub socket_ConnectionRequest(index As Integer, ByVal RequestID As Long)
Call AcceptConnection(RequestID)
End Sub
It should work fine, It works for me.
The problem was that you where closing the Socket(0) on your AcceptConnection() function.
The Socket(0) should never be closed, since it's the socket that listen for all the others.