Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: multithreading winsock control vb


Message #1 by "hemali sutaria" <hemalisutaria@y...> on Tue, 16 Jul 2002 14:14:08
i want to develop mail server in vb
for that i required to do multithreading using WINSOCK control
i've written following code in connectionrequest event


Private Sub wsckServer_ConnectionRequest(ByVal requestID As Long)
    Dim objClient   As clsSMTPClient
    Dim objWinSock  As MSWinsockLib.Winsock
    Dim lngThreadID As Long

    Load wsckClient(wsckClient.Count)
    Set objWinSock = wsckClient(wsckClient.Count - 1)

    Set objClient = CreateObject("MTSMTP.clsSMTPClient")

    lngThreadID = objClient.ThreadID

    If mcolSMTPClients Is Nothing Then
        Set mcolSMTPClients = New Collection
    End If
    
    Set objClient.ClientWinsock = objWinSock
    mcolSMTPClients.Add objClient, Key:="C" & lngThreadID
    
    Set objClient = Nothing
    Set objClient = mcolSMTPClients("C" & lngThreadID)
    Set objClient.SMTPServer = Me
    objClient.ClientWinsock.Accept requestID

    AddToTextBox objClient.ThreadID

    lblClientsConnected.Caption = "Clients Connected: " & 
mcolSMTPClients.Count

    DoEvents
    objClient.SendData "220 Welcome to " & wsckServer.LocalHostName & 
vbCrLf
    DoEvents
End Sub



but when 'end sub' statement gets executed once, winsock socket is closed 
automatically though we have stored it in collection and 'connection to 
host lost' message is displayed at telnet (client side)

Can you help me out regarding this proble
please reply soon
thanks
hemali sutaria

  Return to Index