I was able to open a connection using TCPClient, it is able to read and write data or string, however when I turn off the remote device or unplug the network cable, then check the client.connecte d property, it always shows "True". what could be happened? Thanks
May 28 '08
15 3362
What I want to detect is whenever the remote device (server) is power off, then the software should be able to know the connection is lost or the socket is disconnected or it is closed and so on. Then the client will try to reconnect it back to the server. but it will fail to do so until the server is powered on again.
Plater 7,872
Recognized Expert Expert
That function I gave you will only tell you if the connected socket you had was closed. It detects physical disconnections (unplugged, power off, etc) as well as software disconnections (server software is closed, server closed connection)
If you are trying to find out if the server is running before connecting to it, that is completely different. And all you would do is turn down the connectiontimeo ut values so that it will return very quickly if no connection can be made.
Thanks Plater,
Where is to set connectiontimeo ut value? is it one of property of socket?
What I want is that the connection is established initially, if the server power off, my software should be able to detect this state change, then close the socket and wait for re-connection when the server power on. Thanks
Is there any way to ping the remote server with the socket in my application? by checking the response, I may detect whether the remote server is power down.
Yes, using "My.Computer.Ne twork.Ping" function is able to detect the remote server power down, it will return false if ping fail.
I have another question regarding the event of data received via network. Since TCPClient does not implement data_received event like Winsock, how can I program an event routine to handle this event? Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Patrick |
last post by:
Hi...
I've written a small client, that uses the TCPClient for connecting to a
server and receives data from the server. When the connection is idle, after
5 minutes I get disconnected from the server. When this happens, I want to
reconnect to the server, but my problem is, I don't know how to find out if
I'm still connected or not.
Any ideas how to get that status?
|
by: user |
last post by:
Hello
How can i read IP of incoming connection when i have TcpClient for that
connection ?
Thanx
|
by: David Dvali |
last post by:
How can I check if TcpClient is connected (or not connected)?
|
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 closes the connection so I can exit my
listener code. Here is what I have tried.
First I asked MSDN and they said..
|
by: Holger Steinestel |
last post by:
Hello,
I have a problem with the TCPClient class.
After closing the connection with the Close() method, the connection on the
Linux server remains open with the CLOSE_WAIT status.
I found the Knowledge Base article #821625 , which recommends to close the
NetworkStream before the TCPClient is closed. However, this does not solve
the problem.
| |
by: pickedaname |
last post by:
I work for a telecom company.
We need to get data from our 5ESS switches to be consumed by a .NET app.
The data I am getting back is incomplete.
For example, the beginning of the first line recvd from the device should
read:
SWT5 5e16(2) 02.00
Instead I get
a bunch of gibberish then SWT5
|
by: Prasanta |
last post by:
Hello,
Please cnay one can tell me how to read mail as formatted.... i have made
some code using that able to read but not able to serialize..... so am i need
to parse the HTML, or is there any class using that i can directly get the
full info ablt the mail, like TO,From,Subject,Body,Attachments,
Below is the code which i develop,
using System;
|
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 server response is received, the GetStream method
will return will return other than wait forever.
thanks in advance,
|
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 fails
by whatever reason. I tried to get the same results with Kamaelia's
TCPClient component. If I start up the component and try to connect
to a closed TCP port it fails and sends a message out of the signal
box, that's okay.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |