473,413 Members | 1,705 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,413 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
Sep 19 '05 #1
0 1076

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

Similar topics

4
by: Christopher H. Laco | last post by:
I'm having a problem with the TcpClient that I can only conclude is either a feature, or a complete misunderstanding of the docs on my part. In a nutshell, I'm simply performing the following...
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...
15
by: jin | last post by:
hi, i'm trying using the tcpClient to get a html file from net, instead of using WebClient or WebRequest, the main part of the source code is like this: private void tcpconnect() { tcp=new...
0
by: Torsten Brasch | last post by:
Hi All and Happy New Year ;) I have a very strange problem with System.Net.Sockets.TcpClient(). For some reason, the number of bytes I can receive is limited to 5460 bytes. I made sure that the...
1
by: hamil | last post by:
I am having trouble using the TcpListener and TcpClient classes. At the end of this post is server code that runs, and a class whose purpose is described below. I need to know when the client...
0
by: Holger Steinestel | last post by:
Hello, I have a problem with the TCPClient class. After closing the connection with the Close() method, the connection on the Linux server remains open with the CLOSE_WAIT status. I found...
0
by: Hawk Wu via DotNetMonster.com | last post by:
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. ...
7
by: david.topham | last post by:
Hi The code below demostrates an issue I'm having with with NetworkStream: using System; using System.Net.Sockets; namespace TCPCTest { class Class1
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?
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:
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
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
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.