Help VBNET Packet Serialize and TCP Socket

  • Thread starter Thread starter Arsium
  • Start date Start date
A

Arsium

Guest
Hello dears,

I'm here because I really need help with my tcpclient.

Server Code :


Public T As New TcpListener(IPAddress.Any, 8080)
Public L As New List(Of TcpClient)

Async Sub Accept_Clients()

Dim C As TcpClient = Await T.AcceptTcpClientAsync
L.Add(C)
Accept_Clients()

End Sub

Public Sub Send_Data(P As PacketMaker)

Dim B As New BinaryFormatter

For Each C As TcpClient In L


B.Serialize(C.GetStream, P)

'MessageBox.Show(C.Client.RemoteEndPoint.ToString)
Next

End Sub

Public Enum PacketType As Integer
MSG = &H5057
End Enum
<Serializable()>
Public Class PacketMaker
Public Property Plugin As Byte()
Public Property Type_Packet As PacketType
End Class


Client Code :


Dim T As New TcpClient
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

T.Connect("127.0.0.1", 8080)

Dim N As NetworkStream = T.GetStream

Task.Run(Sub() R(N))

End Sub



Public Sub R(ByVal L As NetworkStream)

Dim sf As BinaryFormatter = New BinaryFormatter()
While True


Dim po As PacketMaker =CType(sf.Deserialize(L),PacketMaker)

MessageBox.Show(PacketType.MSG)

End While

End Sub





Public Enum PacketType As Integer
MSG = &H5057
End Enum
<Serializable()>
Public Class PacketMaker
Public Property Plugin As Byte()
Public Property Type_Packet As PacketType
End Class


The client doesn't work as expected even with low size data. The messagebox doesn't appear any ideas ?

Continue reading...
 
Back
Top