Making a multi-room server that emulates the battle.net's CHAT protocol.
However, sometimes (seemingly randomly) clients will no longer be able to connect, and will be disconnected with with an error description of "forcefull rejected." ConnectionRequest isn't even being called, anyone know why this is happening?
ConnectionRequest:
Private Sub sckServer_ConnectionRequest(ByVal requestID As Long)
'allow him to connect
loadclient requestID
'check to see if he's ipbanned
'check to see if he has too many
'bots loaded.
Text1.Text = sckClients.UBound
End Sub
loadclient():
Public Sub loadclient(ByRef RID As Long)
frmMain.sckServer.Close
DoEvents
frmMain.sckServer.Listen
DoEvents
Dim index As Integer
Dim port As Long
index = getopen
If index = -1 Then
Load frmMain.sckClients(frmMain.sckClients.UBound + 1)
ReDim Preserve clients(UBound(clients) + 1)
index = UBound(clients)
End If
With clients(index)
.access = ACCESS_USER
.constate = CONSTATE_WAITING
.socketindex = index
End With
With frmMain.sckClients(index)
.Close
.LocalPort = PORT_START + index
.Accept RID
.SendData "Connection from [" & .RemoteHostIP & "]" & vbCrLf & vbCrLf & "0x03 (LOGINCHALLENGE)" & vbCrLf & "0x04 (NOECHO)" & vbCrLf & "0x0C (MAKEACCT)" & vbCrLf & vbCrLf
DoEvents
End With
End Sub
getopen (used so another instance of 'sckClients'
isn't created needlessly):
Private Function getopen() As Integer
Dim i As Integer
For i = 1 To UBound(clients)
If frmMain.sckClients(i).State <> 7 Then getopen = i: Exit Function
Next i
getopen = -1
End Function
uh
dont use vb.
I'm to tired to read the code right now but its possible that somewhere the listening socket is being closed and left closed instead of reopened. That's happened to me a couple times, good luck.
This was just another stupid mistake by me... ::)
Apparently you don't need to close the socket that's listening at all.