473,804 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: TCP listener - check for connection status

On Wed, 06 Aug 2008 08:33:55 -0700, Markgoldin <ma************ *@yahoo.com>
wrote:
tcpl = new TcpListener(ipe );
TcpClient tcpc = tcpl.AcceptTcpC lient();
while (true)
{
// get data
while (true)
{
// if contidion met break;
}
}

How can I check if a client has been disconnected from the listener?
Try to send something.

Connection status can only be determined when you send data. If the
connection is broken when you send data, you'll get an exception.
Otherwise, you won't receive any notification.

You can design your protocol to send periodic "keep alive" messages, but
that's not usually the right thing to do. It's a _good_ thing that TCP
doesn't detect a broken connection until you actually try to use it. That
allows transient problems to occur without affecting your connection.

Pete
Aug 6 '08 #1
1 5722
Good answer. When you think about it, it would not even be possible without
some kind of keepalive because your never going to get any back channel
notification that the host is down or a link was broken until you actually
try to send a packet. Unless your waiting on some push notification deal, a
keepalive is not desired anyway.

--william

"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Wed, 06 Aug 2008 08:33:55 -0700, Markgoldin <ma************ *@yahoo.com>
wrote:
>tcpl = new TcpListener(ipe );
TcpClient tcpc = tcpl.AcceptTcpC lient();
while (true)
{
// get data
while (true)
{
// if contidion met break;
}
}

How can I check if a client has been disconnected from the listener?

Try to send something.

Connection status can only be determined when you send data. If the
connection is broken when you send data, you'll get an exception.
Otherwise, you won't receive any notification.

You can design your protocol to send periodic "keep alive" messages, but
that's not usually the right thing to do. It's a _good_ thing that TCP
doesn't detect a broken connection until you actually try to use it. That
allows transient problems to occur without affecting your connection.

Pete
Aug 6 '08 #2

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

Similar topics

1
3743
by: Cherrish Vaidiyan | last post by:
sir, I have a small error in Listener configuration.I have two system with a database in each. I am using Red Hat 9 and Oracle 9i. so i shall anme the database and system. system 1 - node2 system 2 - node3 database - apple database - intel i have installed Oracle on 'node3' by copying the files and then creating a new database in it. Now i want to configure listener. I
5
13435
by: Axel Dachtler | last post by:
Hi, I have a listener problem. The listener cannot read SERVICE_NAME in TNS-Descriptor. The service-name I specified in Oracle Net Manager for this database is testdb as well. (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=axel-0560nntbn1) (PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=testdb))) It is a local database so I tried testdb.localhost, but this didn't
6
16700
by: Ellen K. | last post by:
Hi all, I'm a developer. While at my current job I've been working with mostly SQL Server, now I need to connect to our Oracle Financials running on HP-UX. The Oracle DBA set me up as a user and installed the Oracle client on my box and I have the tnsnames file, but I still can't establish a connection to the database from my development environment... I'm getting an error message "ORA-12224 TNS:no listener".
1
3011
by: Agnes | last post by:
in form_load, i will new a sql connection ,fill in the dataset and then close the connection. I use Netstat to check the status. (1)Open the form , The status to the SQL server is "ESTABILISHED" (2)Close the form, The status is "TIME_WAIT" (3)WAIT a sec. that thread is disappear . my question is , I had closed the connection after fill in , WHY the status still become "ESTABLISHED" ? , if the user open 10 forms, there will be 10 thread...
2
2723
by: Pete | last post by:
Hi All, I am using VB.NET and TCP/IP synchronous sockets to connect to listener software on another machine. I was wondering if anyone could help me understand how to automatically detect and re-establish the connection to the workstation the listener software is running on if it goes "down" for any reason . . . TIA,
5
38838
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point, I believe another set of eyes on the issue is merited. I am a MSSQL DBA and somewhat new to ORACLE; but I have read the administrators manual having a basic thorough level of knowledge (Tho' I am still learning) and understanding of how to...
4
11293
by: Sir C4 | last post by:
Can someone give a quick example of how to check for activity on a TCP port? For example, I'd like to watch and listen for activity on port 80. Once activity is detected, I'd like an event to be triggered. Thanks in advanced.
1
1408
by: tensi4u | last post by:
Hello, everyone. I began to work with DB2 V8.1 for Linux on debian from last month, I'm beginner to DB2, and I have two questions. First, searched articles related to "number of connection" at the forum, everyone recommended to use "Event monitor" and "Snapshot", it needs to connect to Database. But, I want to know how can I get the number of connection at a current point of view without connection to DB2. For example, under the...
1
3180
by: michael ngong | last post by:
michael.john@gmx.at (Michael John) wrote in message news:<90cc4edd.0306230900.28075193@posting.google.com>... MIchael I you stated the OS and platform that could make it easier to address your issue Michael Tubuo Ngong
0
10340
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 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...
0
10085
tracyyun
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...
0
9161
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, 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...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.