Login  
Search All Forums
Dart Home | PowerTCP Sockets for .NET | Custom Development Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
AuthorForum: PowerTCP Sockets for .NET (Secure and Standard)
Topic: Connection question
random0000

From: Las Vegas, NV USA
Posts: 4
Member Since: 06/27/03
posted July 2, 2003 8:27 PM

I am trying to create a server that can handle hundreds of connections (not all at once but at the 50/sec or so mentioned on the product details. So I created the below code to connect multiple clients to a server that does nothing but read any client input.

The first issue I had was the connections would be refused if I set the threading.sleep too low (i.e. 200 ms). Shouldn't it be able to handle many connections/second? I should be able to go down to 20ms which would be 50 connections/second right?

The second issue I had was that I had to manually adjust the # of threads the CLR allows to be able to create 100 connections. Why does the control use threadpools rather than regular threads which would be unlimited?

What is a better approch to do this? Thanks for any answers and help!

Client side:
Public Sub main()
    Dim x(100) As Dart.PowerTCP.SslSockets.Tcp
    Dim i As Integer

    For i = 0 To 100
      x(i) = New Dart.PowerTCP.SslSockets.Tcp
      Threading.Thread.Sleep(500)
      x(i).Connect("zitsponti", 10000)
      Console.WriteLine(i)
    Next

    While 4 = 4
      Application.DoEvents()
    End While
  End Sub

Server side:
Private Sub Server1_Connection(ByVal sender As Object, ByVal e As Dart.PowerTCP.SslSockets.ConnectionEventArgs) Handles Server1.Connection
    Try
      Do While (e.Tcp.Connected) ' This is true until client closes the connection.
        Dim s As String = e.Tcp.Receive().ToString()
        'e.Tcp.Send(s)
        Console.WriteLine(e.Tcp.RemoteEndPoint.Address.ToString & ":" & s)
      Loop
    Catch ex As Exception
      ' just eat any exceptions
    End Try
  End Sub
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted July 3, 2003 9:52 AM

Hi,
The first thing you should do is remove the Sleep, and use the array of Tcp components asynchronously (use the BeginXXX methods, like BeginConnect).
Each instance will then work on its own thread.
-ken
Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX