Valhalla Legends Forums Archive | Visual Basic Programming | CHAT Server - stops listening [fixed]

AuthorMessageTime
Eli_1
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:
[code]
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
[/code]




loadclient():
[code]
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
[/code]

getopen (used so another instance of 'sckClients'
isn't created needlessly):
[code]
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
[/code]
June 23, 2004, 2:31 AM
St0rm.iD
uh

dont use vb.
June 23, 2004, 2:53 AM
Eli_1
[quote author=vL admins are immature :P link=board=31;threadid=7397;start=0#msg66748 date=1087959181]
uh

dont use vb.
[/quote]

uh

dont post in the vb forum.
June 23, 2004, 3:03 AM
Fr0z3N
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.
June 23, 2004, 4:07 AM
Eli_1
This was just another stupid mistake by me... ::)
Apparently you don't need to close the socket that's listening at all.
June 23, 2004, 5:34 PM

Search