Click to See Complete Forum and Search --> : cannot connect to listening socket
aneu
Sep 22nd, 2005, 11:52 AM
so... i am trying to make a dc++ hub software, but i have a little problem. when more people try to connect it says "connection refused" to some peoples... if i try to reconnect, it finally connects me after i retry a few times (sometimes one, sometimes 20)... i saw that the connection request event does not occur sometimes, even if the winsock is listening on that port!!! what can i do? i tried to listen on another port, and i had the same problem
Pino
Sep 22nd, 2005, 11:55 AM
post the code :)
aneu
Sep 22nd, 2005, 12:01 PM
so... this is the code:
Sub StartHub()
PrintError Date & " " & Time & " -> Starting hub..."
On Error GoTo Repara
Dim Aux As String
Dim NrWinsockListen As Byte
Dim Aux2 As String
NrWinsockListen = 0
Aux = ""
For i = 1 To wskListenExtra.Count - 1
Unload wskListenExtra(i)
Next
If txtExtraListenPorts.Text <> "" Then: Aux = txtExtraListenPorts.Text & " "
Do While InStr(Aux, " ") <> 0
Aux2 = Mid$(Aux, 1, InStr(Aux, " ") - 1)
If NrWinsockListen > 0 Then
If wskListenExtra.Count <= NrWinsockListen Then: Load wskListenExtra(NrWinsockListen)
End If
wskListenExtra(NrWinsockListen).Close
wskListenExtra(NrWinsockListen).LocalPort = Val(Aux2)
wskListenExtra(NrWinsockListen).Listen
Aux = Mid$(Aux, InStr(Aux, " ") + 1, Len(Aux))
NrWinsockListen = NrWinsockListen + 1
Loop
UpDays = 0
UpHours = 0
UpMins = 0
UpSecs = 0
wskConnect(0).LocalPort = ListenPort
wskConnect(0).Listen
HubRunning = True
cmdStartStopHub.Caption = "Stop Hub"
StatusBar.Panels(1).Text = "Running..."
Exit Sub
Repara:
MsgBox Err.Description, vbOKOnly, "Error"
Err.Clear
Resume Next
End Sub
Private Sub wskConnect_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim i As Integer
Dim NrWskGasit As Integer
'if it is not the first winsock loaded
If (wskConnect.Count - 1) > 0 Then
For i = 1 To wskConnect.Count - 1
If wskConnect(i).State <> 7 Then
wskConnect(i).Close
wskConnect(i).Accept requestID
NrWskGasit = i
GoTo Gasit
End If
Next
'if it is the first user
Else
ReDim User(1)
Load wskConnect(1)
wskConnect(1).Accept requestID
NrWskGasit = 1
GoTo Gasit
End If
'if i haven't found a free winsock and i have to load a new one
Load wskConnect(wskConnect.Count)
ReDim Preserve User(wskConnect.Count - 1)
wskConnect(wskConnect.Count - 1).Accept requestID
NrWskGasit = wskConnect.Count - 1
Gasit:
DoEvents
If wskConnect(NrWskGasit).State = 7 Then: wskConnect(NrWskGasit).SendData "$Lock " & HubLock & " Pk=AneuHub10Beta|<" & HubSecurity & "> This Hub is running version 1.0 beta of AneuHub (RunTime:" & lblUptime.Caption & ").|" & "$Supports OpPlus NoGetINFO NoHello UserIP2|$HubName " & HubName & "|"
End Sub
the idea is that it listens... but the users cannot connect every time... i think it is a winsock bug, not my bug
aneu
Sep 23rd, 2005, 04:50 AM
any ideas??? i am completely stuck!!!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.