Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Eli_1 on June 22, 2004, 09:31 PM

Title: CHAT Server - stops listening [fixed]
Post by: Eli_1 on June 22, 2004, 09:31 PM
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
Title: Re:CHAT Server - stops listening (?)
Post by: Banana fanna fo fanna on June 22, 2004, 09:53 PM
uh

dont use vb.
Title: Re:CHAT Server - stops listening (?)
Post by: Eli_1 on June 22, 2004, 10:03 PM
Quote from: vL admins are immature :P on June 22, 2004, 09:53 PM
uh

dont use vb.

uh

dont post in the vb forum.
Title: Re:CHAT Server - stops listening (?)
Post by: Fr0z3N on June 22, 2004, 11:07 PM
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.
Title: Re:CHAT Server - stops listening [fixed]
Post by: Eli_1 on June 23, 2004, 12:34 PM
This was just another stupid mistake by me...  ::)
Apparently you don't need to close the socket that's listening at all.