By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,426 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

TCP send & Recieve

P: n/a
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


May 1 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try not using the close statements at the end. You are disconnecting
yourself with these statements.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
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

May 1 '06 #2

P: n/a
This did not help in any way it still continues behaves in the same manner.

"vbnetdev" <vb******@community.nospam> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Try not using the close statements at the end. You are disconnecting
yourself with these statements.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
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


May 1 '06 #3

P: n/a
Hi,

Send zipped project to

ad***@nospamkjmsolutions.com

remove no spam and let me see what I can do.

Kelly

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:uP*************@TK2MSFTNGP03.phx.gbl...
This did not help in any way it still continues behaves in the same
manner.

"vbnetdev" <vb******@community.nospam> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Try not using the close statements at the end. You are disconnecting
yourself with these statements.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
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



May 1 '06 #4

P: n/a
Kelly,

worked it out, the solution is to the place all the processing items
within the do while loop this ensures that the active listener is active and
ready.

"vbnetdev" <vb******@community.nospam> wrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
Hi,

Send zipped project to

ad***@nospamkjmsolutions.com

remove no spam and let me see what I can do.

Kelly

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:uP*************@TK2MSFTNGP03.phx.gbl...
This did not help in any way it still continues behaves in the same
manner.

"vbnetdev" <vb******@community.nospam> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Try not using the close statements at the end. You are disconnecting
yourself with these statements.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Tlink" <Tl***@online.nospam> wrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
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




May 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.