Results 1 to 2 of 2

Thread: Winsock Guru Needed

  1. #1

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935

    Winsock Guru Needed

    Okay I have been battling away for some time trying to get a winsock connection working within my app.

    I have written previous apps using the same code and it has worked fine. But now all I get is either "Address in Use Error" or if I change the ports to be 0 to let winsock determine the port I simple get nothing this is driving me insane

    Here is the code im using

    VB Code:
    1. Private Sub Form_Activate()
    2. Dim strIp As String
    3.  
    4. If isLoaded = False Then
    5.     strIp = SckListen(0).LocalIP
    6.     SckListen(0).LocalPort = 1001
    7.     SckListen(0).Listen
    8.     objData.addChatUser User, strIp
    9.    
    10.     If isDemo = True Then
    11.         demoValidate
    12.     End If
    13.    
    14.     isLoaded = True
    15. End If
    16. End Sub
    17.  
    18.  
    19.  
    20. Private Sub SckListen_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    21. If SckListen(0).State <> sckClosed Then SckListen(0).Close
    22.  
    23. If Index = 0 Then
    24.             intSckIndex = intSckIndex + 1
    25.             Load SckListen(intSckIndex)
    26.             SckListen(intSckIndex).LocalPort = 0
    27.             SckListen(intSckIndex).Accept requestID
    28. End If
    29.  
    30.  
    31. End Sub
    32.  
    33. 'In another form
    34.  
    35. Private Sub cmdChat_Click()
    36. Dim txtSelected
    37. Dim intCount As Integer
    38. Dim isSel As Boolean
    39. Dim strSend As String
    40. Dim strChatName As String
    41. Dim strHost As String
    42. Dim isConnect As Boolean
    43.  
    44. isSel = False
    45.  
    46. For intCount = 0 To List1.ListCount - 1
    47.     If List1.Selected(intCount) = True Then
    48.         isSel = True
    49.     End If
    50. Next intCount
    51.  
    52. If isSel = False Then
    53.     msg = MsgBox("Please Select a user!", vbInformation)
    54.     Exit Sub
    55. End If
    56.  
    57. Set frmChat = New frmClientChat
    58. intFrmChatCount = FrmChatCol.count + 1
    59. strChatName = User & " Session " & intFrmChatCount
    60. frmChat.Tag = strChatName
    61. FrmChatCol.Add frmChat, frmChat.Tag
    62.  
    63.  
    64.  
    65. For intCount = 0 To List1.ListCount - 1
    66.     If List1.Selected(intCount) = True Then
    67.         intSckIndex = intSckIndex + 1
    68.         Load frmDesktop.SckListen(intSckIndex)
    69.         strHost = objData.getChatHost(List1.List(intCount))
    70.         frmDesktop.SckListen(intSckIndex).Connect strHost, 1001
    71.         If frmDesktop.SckListen(intSckIndex).State = sckConnected Then
    72.                 strSend = "REQUEST" & Chr$(182) & User & Chr$(182) & strChatName
    73.                 frmDesktop.SckListen(intSckIndex).SendData strSend
    74.             End If
    75.        
    76.        
    77.     End If
    78. Next intCount
    79.  
    80. frmChat.Show
    81. Unload Me
    82.  
    83. End Sub

    that last sub is little dodgy now as I have been playing around with it trying out different stuff

    Can someone anyone please help me sort this out ??


    Thanks

  2. #2

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    Anybody?????

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