| Dart Home | PowerTCP Sockets for .NET | Custom Development | Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
| Author | Forum: PowerTCP Sockets for .NET (Secure and Standard) Topic: Keep the connection alive |
| tbahri tbahri@gmail.com From: Manama, Bahrain Posts: 1 Member Since: 10/15/08 |
posted October 15, 2008 4:37 AM Hello i am using release 1.1.1.0 from the Power Sockets I am using a server component on VB.NET (and C#.NET) after I accept the connection it seems taht the connection is automatically closed. I need to keep the connection alive with the client until the client close it. no matter how long the connection goes ... it should always stay alive until the client disconnect or the communication line cut. thank you |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted October 20, 2008 12:47 PM Please review the "Using the Server Component" section in the help file. When you call the Listen method on the server and an incoming connection occurs then the connection event is raised. To keep the connection alive until the Client terminates it, you need to loop on the connection status of the TCP connection as demonstrated in the help section. Ex: ' Begin listening on port 7 (the well-known port for echo) Server1.Listen(7) Private Sub Server1_Connection(ByVal sender As Object, ByVal e As Dart.PowerTCP.Sockets.ConnectionEventArgs) Handles Server1.Connection ' The Tcp instance used to communicate with the client is ' found in e.Tcp. Try ' Keep receiving and echoing until the client closes the connection Do While (e.Tcp.Connected) ' This is true until client closes the connection. ' Receive the data from the client. Dim s As String = e. Tcp.Receive ().ToString() ' Send the data back to the client e.Tcp.Send(s) Loop Catch ex As Exception ' just eat any exceptions End Try End Sub ------ |
| Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|