listener.stop - all connections or what?

Drstein99

Well-known member
Joined
Sep 26, 2003
Messages
283
Location
Audubon, Nj
I have a thread that listens for connections. My application works in a way where after the first connection, i want to stop receiving connections. Its adapted from a popular sample tcp/ip around the internet using threading.

--

When a connection is pending, it executes;

dTest = listener.AcceptSocket

---

I am finding, when the LISTENER.STOP command is issued, I beleive the dTest socket is shut down. I want the dTest SOCKET to be a separate object, apart from the listener. when i issue the listener.stop - i dont want it to affect that socket.

---

Can someone advise me please? I lack the experience in tcp/ip (also threading), this is my first project, but I am a versed programmer in database. Thanks.
 
I will give it my best shot. This is some REDUCED code.
----

Private Sub DoListen()
Dim bIpLoop As Integer = -1

Listen for new connections.

Console.WriteLine(Now.ToString & " listen start")

listener.Start()


RaiseEvent addhand(Nothing, "LISTMESSAGE|SOCKET STARTED|" & IIf(bAcceptMany = True, "Accept many connects", "Accept single connect"))
Do

If bAcceptingConnections Then
If listener.Pending Then
Console.WriteLine(Now.ToString & " lthread is true and pending is true")

avTemp = New avatar(listener.AcceptSocket, sFromAvatar)

If bAcceptMany = False Then

RaiseEvent addhand(avTemp, "ADDNEW")

avTemp.StartCall2()
listener.Stop()
bAcceptingConnections = False
Console.WriteLine(Now.ToString & " after add new avatar")


ElseIf Not ipFound(avTemp.ipAddress) Is Nothing Then
avTemp.StartCall2(-1)

RaiseEvent addhand(avTemp, "ERRORMSG|Duplicate catch detected!")
Else

RaiseEvent addhand(avTemp, "ADDNEW")

avTemp.StartCall2()
Console.WriteLine(Now.ToString & " after add new avatar")


End If
End If

End If

Application.DoEvents()

Loop Until lThread = False

RaiseEvent addhand(Nothing, "LISTMESSAGE|Thread exiting")

Console.WriteLine(Now.ToString & " lthread is false, listener stopped")

End Sub

-----

The "avatar" a custom object is inherited from a listview object. the socket is inside the avatar object.
 
Back
Top