473,385 Members | 1,465 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,385 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 11329
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.