473,408 Members | 1,852 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,408 software developers and data experts.

TCPClient Close have odd problem

Hello,
I have odd problem. When I close my application wait around 5 minute. The
pocket of screen will show one message "System.Net.Sockets.Tcpclient" of
message box. My source code as below.

Dim t1 as TcpClient
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles MyBase.Load
Dim bf(255) As Byte
t1.GetStream.BeginRead(bf, 0, 255, AddressOf DoRead, Nothing)
Dim sw As StreamWriter = New StreamWriter(t1.GetStream)
sw.Write("CONNECT|Hello")
sw.Flush()
End Sub

Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.
ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim sw As StreamWriter = New StreamWriter(t1.GetStream)
sw.Write("DISCONNECT|Hello")
sw.Flush()
t1.Close()
Application.Exit()
End Sub
Private Sub DoRead(ByVal AR As IAsyncResult)
Dim bf(255) As Byte
Dim Rby As Integer
Dim RDstr As String
Try
Rby = t1.GetStream.EndRead(AR)
If Rby < 1 Then
Exit Sub
End If
RDstr = Encoding.ASCII.GetString(bf, 0, Rby - 2)
Por(RDstr)
t1.GetStream.BeginRead(bf, 0, 255, AddressOf DoRead, Nothing)
Catch ex As Exception
MessageBox.Show(ex.Message)
Catch ex1 As SocketException
MessageBox.Show(ex1.Message)
End Try
End Sub
Sub Por(ByVal RDStr As String)
Dim RdArr() As String = RDStr.Split("|")
MessageBox.Show(RdArr(0))
End Sub

Please kindly help. thanks
--
Message posted via http://www.dotnetmonster.com
Nov 22 '05 #1
0 825

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

Similar topics

3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
3
by: מורדי | last post by:
Hi, I'm writing a client/server application in which the client send a series of screenshots to the server to be saved using the tcpclient. in most cases the first screenshot is transmitted ok...
2
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
3
by: מורדי | last post by:
Hi, I'm writing a client/server application in which the client send a series of screenshots to the server to be saved using the tcpclient. in most cases the first screenshot is transmitted ok...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
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,...
0
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...
0
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...

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.