T
Tlink
I have have lifted some code that I am trying to make work in 2 seperate
projects it appears to send okay but the it only recieves once then it stop
recieving I am unsure as to why ?
******** sending ****
Private Sub SendAction(ByVal DoAction, ByVal RemoteAddress)
Dim Actionport As Integer = 40000
Dim TCPClient As New TcpClient(RemoteAddress, Actionport)
Dim TCPNetworkStream As NetworkStream = TCPClient.GetStream
Dim TCPStreamWriter As New StreamWriter(TCPNetworkStream)
Try
TCPStreamWriter.Write(DoAction)
Catch ex As Exception
ErrorCondition = ex.Message
End Try
TCPStreamWriter.Close()
TCPNetworkStream.Close()
TCPClient.Close()
End Sub
****** recieving *****
Dim localhostaddress As IPAddress = MSearchObj.ActiveIP
Dim Lport As Integer = 40000
Dim TcpListener As New TcpListener(localhostaddress, Lport)
TcpListener.Start()
Dim TCPClient As TcpClient = TcpListener.AcceptTcpClient()
Dim TCPNetworkStream As NetworkStream = TCPClient.GetStream
Dim TCPStreamReader As New StreamReader(TCPNetworkStream)
errorcondition = ""
Do While errorcondition.Length = 0
RecievedData = ""
SendData = ""
If TcpListener.Pending = False Then
Thread.Sleep(100)
Else
Do While TCPStreamReader.EndOfStream = False
RecievedData = TCPStreamReader.ReadLine
If RecievedData <> "" Then
ProcessInput(RecievedData, SendData, MSearchObj,
DBobj)
End If
Loop
Thread.Sleep(1000)
End If
Loop
projects it appears to send okay but the it only recieves once then it stop
recieving I am unsure as to why ?
******** sending ****
Private Sub SendAction(ByVal DoAction, ByVal RemoteAddress)
Dim Actionport As Integer = 40000
Dim TCPClient As New TcpClient(RemoteAddress, Actionport)
Dim TCPNetworkStream As NetworkStream = TCPClient.GetStream
Dim TCPStreamWriter As New StreamWriter(TCPNetworkStream)
Try
TCPStreamWriter.Write(DoAction)
Catch ex As Exception
ErrorCondition = ex.Message
End Try
TCPStreamWriter.Close()
TCPNetworkStream.Close()
TCPClient.Close()
End Sub
****** recieving *****
Dim localhostaddress As IPAddress = MSearchObj.ActiveIP
Dim Lport As Integer = 40000
Dim TcpListener As New TcpListener(localhostaddress, Lport)
TcpListener.Start()
Dim TCPClient As TcpClient = TcpListener.AcceptTcpClient()
Dim TCPNetworkStream As NetworkStream = TCPClient.GetStream
Dim TCPStreamReader As New StreamReader(TCPNetworkStream)
errorcondition = ""
Do While errorcondition.Length = 0
RecievedData = ""
SendData = ""
If TcpListener.Pending = False Then
Thread.Sleep(100)
Else
Do While TCPStreamReader.EndOfStream = False
RecievedData = TCPStreamReader.ReadLine
If RecievedData <> "" Then
ProcessInput(RecievedData, SendData, MSearchObj,
DBobj)
End If
Loop
Thread.Sleep(1000)
End If
Loop