473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Detect TcpClient Connection dropped

Jck
Could someone tell me how to detect TcpClient connection dropped, please?

I have a TcpClient connected to a server by IP and Port. The TcpClient only
read data from the server. However, if there is no data received from the
server for a period of time, I am unable to determine whether the connection
is dropped or simply no data is sent from the server.

Work around:
Currently, I am trying to send data with 0 length to detect the connection.
But I want to have a proper way to do it. Please help!

While True
Try
myTcpClient.GetStream().Write(MySendBuffer, 0, 0)
Catch ex As Exception
' Assume connection dropped
Exit While
End Try
Application.DoEvents()
End While
Aug 3 '06 #1
2 4151
Jck,

A few years back I had the same issues. I never found a workaround
with 1.0/1.1 framework. I ended up using 3rd party tool
www.genuinechannels.com for my TcpClient.

Cheers,
Rob Panosh

Jck wrote:
Could someone tell me how to detect TcpClient connection dropped, please?

I have a TcpClient connected to a server by IP and Port. The TcpClient only
read data from the server. However, if there is no data received from the
server for a period of time, I am unable to determine whether the connection
is dropped or simply no data is sent from the server.

Work around:
Currently, I am trying to send data with 0 length to detect the connection.
But I want to have a proper way to do it. Please help!

While True
Try
myTcpClient.GetStream().Write(MySendBuffer, 0, 0)
Catch ex As Exception
' Assume connection dropped
Exit While
End Try
Application.DoEvents()
End While
Aug 3 '06 #2
i suggest using sockets for this. when one users ends the connection, your
informed in code. Also, you can check using properties to see if theres an
active connection
--
-iwdu15
Aug 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Kennedy [UB] | last post by:
Hi, I have a project using the TcpClient and its associated NetworkStream. Everything works well except for one condition which I haven't found any information about dealing with: How do I...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
1
by: chris | last post by:
Is it possible to keep open more than one connection to different servers with only one TcpClient? If no, is it safe to create about 50 instance of TcpClient class? Thanks!
5
by: Jeff Weber | last post by:
First, my question: Should I use Write or BeginWrite (sync or async) to stream data to my clients over a TCPClient connection. Details: On the server I have a custom circular data buffer that...
3
by: Szafranr | last post by:
Hi I have application where I used tcpListener to connect with another system. Every thing is ok that it's time to error handling and I have problem when the TCP client is disconect I don't...
1
by: hamil | last post by:
I am having trouble using the TcpListener and TcpClient classes. At the end of this post is server code that runs, and a class whose purpose is described below. I need to know when the client...
5
by: TulasiKumar | last post by:
Hi all, I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet in c#.Net.Any body knows please tell me, what are the interfaces or classes are supported regrading on TCP/IP...
4
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am wondering if I am using TCPClient class in C#, how to setup timeout value? Timeout I mean, when connects to server for the 1st time, and during <timeoutinterval, if no...
6
by: Bjoern Schliessmann | last post by:
Hello, I'm currently trying to implement a simulation program with Kamaelia and need a reliable TCP connection to a data server. From Twisted, I know that a method is called if the connection...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.