My winsock troubles:
Hi all,
I have a Embeedded VB app running on a Win CE device that needs to send data to a VB.NET service running on Win2K. The Embedded VB uses the standard Winsock control and the sendata command to send a string to the VB.NET application. Trouble is, I seem to be getting an empty network stream on the VB.NET box.
Any suggestions are appreciated.
-Brian
On the handheld:
Outbound connection is a winsock activeX control. It uses TCP and port 10101.
frmMain.OutboundConnection.Connect
frmMain.OutboundConnection.SendData ("Hello World!"
frmMain.OutboundConnection.Close
On the VB.net machine
dim m_Listener as TCP Listener
Dim client As TcpClient
Dim nstm As NetworkStream
Dim intJ As Int32
dim blnNeedPrint as boolean
client = m_Listener.AcceptTcpClient
client.ReceiveBufferSize = 1024
Do
Dim arrByte(client.ReceiveBufferSize) As Byte
nstm = client.GetStream
If nstm.DataAvailable = True Then
If nstm.CanRead Then
nstm.Read(arrByte, 0, CInt(client.ReceiveBufferSize))
End If
'this bit checks to see if we actually have any data. There never is any
For intJ = 0 To UBound(arrByte)
If arrByte(intJ) <> 0 Then
blnNeedPrint = True
End If
Next
If blnNeedPrint = True Then
Me.TextBox1.Text = System.Text.Encoding.ASCII.GetString(arrByte)
End If
End If
Me.Refresh()
Loop
m_Listener.Stop()
m_Listener = Nothing
End Sub
Hi all,
I have a Embeedded VB app running on a Win CE device that needs to send data to a VB.NET service running on Win2K. The Embedded VB uses the standard Winsock control and the sendata command to send a string to the VB.NET application. Trouble is, I seem to be getting an empty network stream on the VB.NET box.
Any suggestions are appreciated.
-Brian
On the handheld:
Outbound connection is a winsock activeX control. It uses TCP and port 10101.
frmMain.OutboundConnection.Connect
frmMain.OutboundConnection.SendData ("Hello World!"
frmMain.OutboundConnection.Close
On the VB.net machine
dim m_Listener as TCP Listener
Dim client As TcpClient
Dim nstm As NetworkStream
Dim intJ As Int32
dim blnNeedPrint as boolean
client = m_Listener.AcceptTcpClient
client.ReceiveBufferSize = 1024
Do
Dim arrByte(client.ReceiveBufferSize) As Byte
nstm = client.GetStream
If nstm.DataAvailable = True Then
If nstm.CanRead Then
nstm.Read(arrByte, 0, CInt(client.ReceiveBufferSize))
End If
'this bit checks to see if we actually have any data. There never is any
For intJ = 0 To UBound(arrByte)
If arrByte(intJ) <> 0 Then
blnNeedPrint = True
End If
Next
If blnNeedPrint = True Then
Me.TextBox1.Text = System.Text.Encoding.ASCII.GetString(arrByte)
End If
End If
Me.Refresh()
Loop
m_Listener.Stop()
m_Listener = Nothing
End Sub