Results 1 to 4 of 4

Thread: cannot connect to listening socket

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    9

    Thumbs down cannot connect to listening socket

    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

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: cannot connect to listening socket

    post the code

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    9

    Re: cannot connect to listening socket

    so... this is the code:

    VB Code:
    1. Sub StartHub()
    2.     PrintError Date & " " & Time & " -> Starting hub..."
    3.     On Error GoTo Repara
    4.     Dim Aux As String
    5.     Dim NrWinsockListen As Byte
    6.     Dim Aux2 As String
    7.     NrWinsockListen = 0
    8.     Aux = ""
    9.     For i = 1 To wskListenExtra.Count - 1
    10.         Unload wskListenExtra(i)
    11.     Next
    12.     If txtExtraListenPorts.Text <> "" Then: Aux = txtExtraListenPorts.Text & " "
    13.     Do While InStr(Aux, " ") <> 0
    14.         Aux2 = Mid$(Aux, 1, InStr(Aux, " ") - 1)
    15.         If NrWinsockListen > 0 Then
    16.             If wskListenExtra.Count <= NrWinsockListen Then: Load wskListenExtra(NrWinsockListen)
    17.         End If
    18.         wskListenExtra(NrWinsockListen).Close
    19.         wskListenExtra(NrWinsockListen).LocalPort = Val(Aux2)
    20.         wskListenExtra(NrWinsockListen).Listen
    21.         Aux = Mid$(Aux, InStr(Aux, " ") + 1, Len(Aux))
    22.         NrWinsockListen = NrWinsockListen + 1
    23.     Loop
    24.     UpDays = 0
    25.     UpHours = 0
    26.     UpMins = 0
    27.     UpSecs = 0
    28.     wskConnect(0).LocalPort = ListenPort
    29.     wskConnect(0).Listen
    30.     HubRunning = True
    31.     cmdStartStopHub.Caption = "Stop Hub"
    32.     StatusBar.Panels(1).Text = "Running..."
    33.     Exit Sub
    34. Repara:
    35.     MsgBox Err.Description, vbOKOnly, "Error"
    36.     Err.Clear
    37.     Resume Next
    38. End Sub
    39.  
    40.  
    41. Private Sub wskConnect_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    42.     Dim i As Integer
    43.     Dim NrWskGasit As Integer
    44.     'if it is not the first winsock loaded
    45.     If (wskConnect.Count - 1) > 0 Then
    46.         For i = 1 To wskConnect.Count - 1
    47.             If wskConnect(i).State <> 7 Then
    48.                 wskConnect(i).Close
    49.                 wskConnect(i).Accept requestID
    50.                 NrWskGasit = i
    51.                 GoTo Gasit
    52.             End If
    53.         Next
    54.     'if it is the first user
    55.     Else
    56.         ReDim User(1)
    57.         Load wskConnect(1)
    58.         wskConnect(1).Accept requestID
    59.         NrWskGasit = 1
    60.         GoTo Gasit
    61.     End If
    62.     'if i haven't found a free winsock and i have to load a new one
    63.     Load wskConnect(wskConnect.Count)
    64.     ReDim Preserve User(wskConnect.Count - 1)
    65.     wskConnect(wskConnect.Count - 1).Accept requestID
    66.     NrWskGasit = wskConnect.Count - 1
    67.  
    68. Gasit:
    69.     DoEvents
    70.     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 & "|"
    71.  
    72. 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
    Last edited by aneu; Sep 22nd, 2005 at 01:25 PM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    9

    Re: cannot connect to listening socket

    any ideas??? i am completely stuck!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width