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