Writing/Reading with NetworkStream
At an interval of 16 ms.
Client sends 4 bytes -> Server receives 0 bytes ???
Server Sends 4 bytes -> client receives 0 bytes ???
Any idea why?
Server code
Sub New(ByVal c As TcpClient, ByVal id As Byte)
Client = c
NS = Client.GetStream
End Sub
' In a List -> In a Class -> Running in a BackgroundWorker
Do
Dim b(3) As Byte, blen As Int16 = 0
NS.Read(b, 0, blen) ' blen is 0
'Irelevant code deleted
If Players.Count > 1 Then NS.Write(XmitData, 0, 4 * (Players.Count - 1)) Else NS.Write(New Byte() {0}, 0, 1) ' transmits 4 bytes
Threading.Thread.Sleep(16)
Loop While Client.Connected = True
Client Code
Public c As New TcpClient
Dim NS As NetworkStream
Sub New(ByVal ip As String)
c.Connect(ip, 4)
NS = c.GetStream
End Sub
'In a timer @ interval = 16 ms'
Dim b(3) As Byte
'irelevant code'
NS.Write(b, 0, 4) ' b = {0,0,244,1}'
Dim br(27) As Byte
Dim blen As Integer
NS.Read(br, 0, blen) ' blen = 0
Muscalu Ștefan ~~~~ Student
View the full article




Sign In
Create Account
Back to top







