473,614 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11377
Isn't this what you are trying to do?

TcpClient.Close Method [Visual Basic]See Also
TcpClient Class | TcpClient Members | System.Net.Sock ets 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 FrameworkLangua ge
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
SocketException An 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(Addre ssFamily.InterN etwork)
' Uses the Close public method to close the network stream and socket.
tcpClient.Close ()
End Sub 'MyTcpClientCom municator

"Haim" <ha**@spetrotec .com> wrote in message
news:%2******** *******@TK2MSFT NGP12.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.Sock ets 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 FrameworkLangua ge
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
SocketException An 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(Addre ssFamily.InterN etwork)
' Uses the Close public method to close the network stream and socket.
tcpClient.Close ()
End Sub 'MyTcpClientCom municator

"Haim" <ha**@spetrotec .com> wrote in message
news:%2******** *******@TK2MSFT NGP12.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%40c pmsftngxa06&rnu m=5&prev=/groups%3Fq%3DTc pClient%2Bclose %2Beve
nt%26hl%3Dzh-CN%26lr%3D%26ie %3DUTF-8%26oe%3DUTF-8%26selm%3D88SA Yc75CHA.1864%
2540cpmsftngxa0 6%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%40c pmsftngxa06&rnu m=5&prev=/groups%3Fq%3DTc pClient%2Bclose %2Beve
nt%26hl%3Dzh-CN%26lr%3D%26ie %3DUTF-8%26oe%3DUTF-8%26selm%3D88SA Yc75CHA.1864%
2540cpmsftngxa0 6%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
3033
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 page dynamically through the use of event listeners in javascript That works, the problem is that when I run the test webpage that runs the ActiveX control, the socket does not start listening for about a minute and a half, after which it runs fine....
3
4622
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 and then fires a datareceived event. Within the waitingloop there is a timeout function, but I want the the 'last-time-socket-used' variable set when the socket is finished sending. When I send by System.Net.Sockets.Socket.Send(buffer()) (<--this...
2
10097
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 TcpListener(IPAddress.Any, 1234); Stream data = null; Socket socket = null;
2
702
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 more data to expect). Sometimes, Socket.Available returns 0 but the other end of the connection did not close it ! 2) This class will be used by many other classes so I have to use the
2
324
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 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
13
2639
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 problem is executing the transactions against the remote server and returning the response to the remoting client. i can open the socket fine and, if i am executing one transaction at a time, everything works great. it's when my proxy server...
9
5534
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. But the "app.MainLoop()" in wxpython looks like conflicting with the "while 1:" in socket server. After I commented the "app.MainLoop()", everything is working except two things: 1. if I click anywhere on the screen with the mouse, the image is...
4
16086
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 the socket again, the bind fails because the port is still in use. When I execute the code in "debug" mode, the problem never occurs. When I execute the same code in release mode, the problem appears about 20% of the time. Here's the code:
0
8198
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, 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...
0
8142
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,...
0
8591
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
7115
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...
1
6093
isladogs
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...
0
4058
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
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
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.