Nikolay,
In addition to the other comments, the following article demonstrates how to
use a BinaryReader & BinaryWriter do send & receive a "message" over a
NetworkStream.
http://msdn.microsoft.com/library/de...rp09182003.asp
The example is in C#, however it should be easily converted to VB.NET, post
if you need help.
I would define a "message" that included a header & detail. The "header"
would include information such as the type of message & possible length of
message.
The "type of message" could be an Integer, an Enum, a String, or a Double,
or a few other things; just about any serializable type; just as long as all
"messages" use the same "type". I would probably use an Enum, as it
encapsulates the types nicely.
For example using an Enum:
Public Enum MessageType As Integer
[String]
[Integer]
datasets
End Enum
Dim writer As BinaryWriter
writer.Write(MessageType.String)
writer.Write("This is the string")
writer.Write(MessageType.Integer)
writer.Write(100)
writer.Write(MessageType.datasets)
' code to write a DataSet to the Stream
Dim reader As BinaryReader
Dim type As MessageType = CType(reader.ReadInt32(), MessageType)
Select Case type
Case MessageType.String
Dim s As String = reader.ReadString()
Case MessageType.Integer
Dim i As Integer = reader.ReadInt32
Case MessageType.datasets
' code to read the DataSet from the stream
End Select
For example using A String:
Dim writer As BinaryWriter
writer.Write("String")
writer.Write("This is the string")
writer.Write("Integer")
writer.Write(100)
writer.Write("datasets")
' code to write a DataSet to the Stream
Dim reader As BinaryReader
Dim type As String = reader.ReadString()
Select Case type
Case "String"
Dim s As String = reader.ReadString()
Case "Integer"
Dim i As Integer = reader.ReadInt32
Case "datasets"
' code to read the DataSet from the stream
End Select
Hope this helps
Jay
"Nikolay Petrov" <jo**************@mail.bg> wrote in message
news:uL**************@TK2MSFTNGP11.phx.gbl...
I need to transfer different types of data from my tcp client to my tcp
server - string, bynary, datasets.
Ho to know what exactly data I receive?