Hi,
I know there exist asynchronous socket methods for connecting,
receiving/sending data and disconnecting - but how do you know when the
socket has been terminated - can you assign an event handler or a
delegate as to when the socket is disconnected - either gracefully from
remote or shut down by "brute force"?
In short, something like this:
MySocket.Close += new EventHandler(My Socket_OnClosed );
Anyone?
Regards,
Vladimir Lushnikov 2 2919
Unfortunately, no, there is no "direct" event for Closing.
When a socket is closed, you will get a receive notification. When you then
try to read from the socket, you will get 0 bytes received. THIS 0 bytes
received is the notification when a socket gets closed.
--
Adam Clauss
"Vladimir Lushnikov" <vl************ ****@gmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. . Hi,
I know there exist asynchronous socket methods for connecting, receiving/sending data and disconnecting - but how do you know when the socket has been terminated - can you assign an event handler or a delegate as to when the socket is disconnected - either gracefully from remote or shut down by "brute force"?
In short, something like this:
MySocket.Close += new EventHandler(My Socket_OnClosed );
Anyone?
Regards, Vladimir Lushnikov
Yes.
There is no "direct" event for Closing
and if you worry about the socket is closed or not . You have to check it by
yourself.
Best Regards,
Vuong
Tran Xuan
"Adam Clauss" <ca*****@tamu.e du> wrote in message
news:11******** *****@corp.supe rnews.com... Unfortunately, no, there is no "direct" event for Closing.
When a socket is closed, you will get a receive notification. When you
then try to read from the socket, you will get 0 bytes received. THIS 0 bytes received is the notification when a socket gets closed.
-- Adam Clauss
"Vladimir Lushnikov" <vl************ ****@gmail.com> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. . Hi,
I know there exist asynchronous socket methods for connecting, receiving/sending data and disconnecting - but how do you know when the socket has been terminated - can you assign an event handler or a delegate as to when the socket is disconnected - either gracefully from remote or shut down by "brute force"?
In short, something like this:
MySocket.Close += new EventHandler(My Socket_OnClosed );
Anyone?
Regards, Vladimir Lushnikov
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hameed Khan |
last post by:
hi all,
i am getting some problems with my first socket
script. can any one of you point me why this is
happening. the server script suppose to accept one
connection at a time and send countdown to client
connected to it from a function through a separate
thread. and echo all the connections opened and
closed. the client script is working fine. it echoes
the countdown it recieve from server.
|
by: James Yang |
last post by:
Hi,
I am using Sockets to connect to a remote computer and send data using
Socket.Send() and receive using Socket.Receive() (block mode) . for
somereason tho, when the client disconnects the Socket.Receive() just passes
without any exception. Is there any way to detect disconnection using
Sockets?
I believe I saw a way of doing this using IAsyncResult, and eventhandling
but..no article really explained how to use it properly.
|
by: dream machine |
last post by:
Hi all,
I'm try to check if the one client socket is really connected at my SocketServer .
I build Client Socket with BeginAccept() ,
and I want to receive data with BegenReceive() call !
The BeginReceive and BeginAccept work very nice .
<Code type="C#">
|
by: Morten |
last post by:
How do I detect if a client socket is no longer connected to the listen tcp
socket ?
I have tried with (just an example):
---------------------
Socket tcpSocket;
while(tcpSocket.Connected)
|
by: Adam Clauss |
last post by:
There seems to be various methods to determine when the remote client disconnects, but all of them I have seen are Synchronous.
AKA: Right before you try to send or receive data, check.
Is there no way to do raise an event for this? That way you know as soon as the client disconnects?
There are events for Accepting, Connecting, Receiving, Sending... why not one for disconnecting?
--
Adam Clauss
cabadam@tamu.edu
| |
by: John Sheppard |
last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand.
Programming environment. VS.NET 2003, C#, Windows XP.
About the architecture:
I have a socket server dll that contains a class that handles connections for a given local ipaddress and port. This class(server) can be started or stopped by calls to the appropriate functions. The server class has...
|
by: Arno |
last post by:
Hi,
I've written a class for client-socket connection, but I get a lot of times
the error message "Unable to read data from the transport connection" when
restart reading the stream with socket.BeginRead in the Sub
SocketIncomingMsg. I'm debugging now for weeks, but I can't detect where it's
going wrong.
the part of code where it fails:
|
by: atlaste |
last post by:
Hi,
In an attempt to create a full-blown webcrawler I've found myself
writing a wrapper around the Socket class in an attempt to make it
completely async, supporting timeouts and some scheduling mechanisms.
I use a non-blocking approach for this, using the call to 'poll' to
support the async mechanism - rather than the 'begin' and 'end'
functions. I already found that connecting doesn't set the
"isconnected" variable correctly...
|
by: craze3 |
last post by:
I have programmed an XML Socket Server to communicate with Flash.
It doesn't print out the messages it has received from the flash until the server has been shut down. Any ideas?
The part with the problem:
//Create streams
BufferedReader data_in = new BufferedReader(
new InputStreamReader(incoming.getInputStream()));
PrintWriter data_out = new...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |