473,396 Members | 1,738 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.

Tcp Socket Close Event

it is very strange for me that a simple event of closing socket that was in
the the winsock object of vb6 ,

i didn't found yet in the vb.net

the only way i found is to try to send something to the socket and if i got
error then the socket is closed.

there must be a way to get this event without trying to send something ,
since it is in the lower level

can you advice please,

thanks in advance,

Haim.
Nov 20 '05 #1
4 11335
Isn't this what you are trying to do?

TcpClient.Close Method [Visual Basic]See Also
TcpClient Class | TcpClient Members | System.Net.Sockets Namespace | Close |
Shutdown | TcpClient Members (Visual J# Syntax) | Managed Extensions for C++
Programming Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
family, .NET Compact FrameworkLanguage
C#

C++

JScript

Visual Basic

Show All
Closes the TCP connection and releases all resources associated with the
TcpClient.
[Visual Basic]
Public Sub Close()
[C#]
public void Close();
[C++]
public: void Close();
[JScript]
public function Close();
Exceptions
Exception TypeCondition
SocketExceptionAn error occurred when accessing the socket. See the Remarks
section for more information.

Remarks
The Close method closes the TCP connection. It calls the Dispose method
passing a true value to release all managed and unmanaged resources
associated with the TcpClient. These resources include the underlying Socket
used for connecting with the remote host, and the NetworkStream used to send
and receive data.
Note If you receive a SocketException, use SocketException.ErrorCode to
obtain the specific error code. Once you have obtained this code, you can
refer to the Windows Socket Version 2 API error code documentation in MSDN
for a detailed description of the error.
Example
[Visual Basic, C#, C++] The following example demonstrates closing a
TcpClient by calling the Close method.
[Visual Basic]
Dim tcpClientD As New TcpClient(AddressFamily.InterNetwork)
' Uses the Close public method to close the network stream and socket.
tcpClient.Close()
End Sub 'MyTcpClientCommunicator

"Haim" <ha**@spetrotec.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
it is very strange for me that a simple event of closing socket that was in the the winsock object of vb6 ,

i didn't found yet in the vb.net

the only way i found is to try to send something to the socket and if i got error then the socket is closed.

there must be a way to get this event without trying to send something ,
since it is in the lower level

can you advice please,

thanks in advance,

Haim.

Nov 20 '05 #2
Isn't this what you are trying to do?

TcpClient.Close Method [Visual Basic]See Also
TcpClient Class | TcpClient Members | System.Net.Sockets Namespace | Close |
Shutdown | TcpClient Members (Visual J# Syntax) | Managed Extensions for C++
Programming Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
family, .NET Compact FrameworkLanguage
C#

C++

JScript

Visual Basic

Show All
Closes the TCP connection and releases all resources associated with the
TcpClient.
[Visual Basic]
Public Sub Close()
[C#]
public void Close();
[C++]
public: void Close();
[JScript]
public function Close();
Exceptions
Exception TypeCondition
SocketExceptionAn error occurred when accessing the socket. See the Remarks
section for more information.

Remarks
The Close method closes the TCP connection. It calls the Dispose method
passing a true value to release all managed and unmanaged resources
associated with the TcpClient. These resources include the underlying Socket
used for connecting with the remote host, and the NetworkStream used to send
and receive data.
Note If you receive a SocketException, use SocketException.ErrorCode to
obtain the specific error code. Once you have obtained this code, you can
refer to the Windows Socket Version 2 API error code documentation in MSDN
for a detailed description of the error.
Example
[Visual Basic, C#, C++] The following example demonstrates closing a
TcpClient by calling the Close method.
[Visual Basic]
Dim tcpClientD As New TcpClient(AddressFamily.InterNetwork)
' Uses the Close public method to close the network stream and socket.
tcpClient.Close()
End Sub 'MyTcpClientCommunicator

"Haim" <ha**@spetrotec.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
it is very strange for me that a simple event of closing socket that was in the the winsock object of vb6 ,

i didn't found yet in the vb.net

the only way i found is to try to send something to the socket and if i got error then the socket is closed.

there must be a way to get this event without trying to send something ,
since it is in the lower level

can you advice please,

thanks in advance,

Haim.

Nov 20 '05 #3
Hi Haim,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you want to get notification when
a socket is closed.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think there is no event fired when the remote point dropped the
connection. In the most scenerio, the event is not necessary. Asynchronous
model for socket gives same ability as the event model.

You may take a look at the link below.

http://groups.google.com/groups?hl=z...&threadm=88SAY
c75CHA.1864%40cpmsftngxa06&rnum=5&prev=/groups%3Fq%3DTcpClient%2Bclose%2Beve
nt%26hl%3Dzh-CN%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D88SAYc75CHA.1864%
2540cpmsftngxa06%26rnum%3D5
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Hi Haim,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you want to get notification when
a socket is closed.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think there is no event fired when the remote point dropped the
connection. In the most scenerio, the event is not necessary. Asynchronous
model for socket gives same ability as the event model.

You may take a look at the link below.

http://groups.google.com/groups?hl=z...&threadm=88SAY
c75CHA.1864%40cpmsftngxa06&rnum=5&prev=/groups%3Fq%3DTcpClient%2Bclose%2Beve
nt%26hl%3Dzh-CN%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3D88SAYc75CHA.1864%
2540cpmsftngxa06%26rnum%3D5
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

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

Similar topics

1
by: mjcast | last post by:
I have been working on an ActiveX control in C#. It is packaged in a Windows Control library and the code is in a user control. The control is used as an automation receiver that is used to update a...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
2
by: Craig | last post by:
Hi I listen on a port, when data is received I raise an event (OnMessageReceived) in the while loop as follows: private void WaitForConnection() { TcpListener listener = new...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
2
by: Haim | last post by:
it is very strange for me that a simple event of closing socket that was in the the winsock object of vb6 , i didn't found yet in the vb.net the only way i found is to try to send something to...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
4
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open...
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
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
marktang
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,...
0
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...
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
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
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...
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.