what i tried to do is to send the first time the lenght of data and then send the data right after.
is it a good idea?
because i don't know how to read until all data is received...
regards
Main Topics
Browse All TopicsHi experts,
I try to send custom objects (dataset/serializable object, etc...) to clients from the server
the communication works fine, and i receive data when i use short string but now, i have implemented server side to send custom objects and since this implementation, i cannot deserialize back in the clients...
what i discovered is when i use customs objects, i received twice call from the server, i'm not sure of it but it seems that the client do a "beginread" to quickly and the server has not enough time to send the object entirely so it sends data "chunked"?
can you help me?
regards
here the Server code to send data to clients :
Dim dataExch As New DataExchange(Subscription,
'serialize the dataExchange class in binary format
ms = ClsMisc.SerializeBinary(Of
If ms IsNot Nothing Then
'convert the memorystream to get a full string to be send in plain text
Data = System.Convert.ToBase64Str
Else
Exit Sub
End If
SyncLock Me._subscriber.GetStream
If Me._subscriber.GetStream.C
Dim writer As New IO.StreamWriter(Me._subscr
writer.Write(Data.ToString
writer.Flush()
End If
End SyncLock
Client code :
Dim BytesRead As Int32
Dim strMessage As String
Try
' Finish asynchronous read into readBuffer and return number of bytes read.
BytesRead = Me._client.GetStream.EndRe
Catch e As Exception
Me.Close()
RaiseEvent onDisconnected(Me)
End Try
If BytesRead < 1 Then
' If no bytes were read server has close. Disable input window.
Me.Close()
RaiseEvent onDisconnected(Me)
Exit Sub
End If
Dim ms As New MemoryStream
Dim b() As Byte = System.Convert.FromBase64S
ms.Read(b, 0, b.Length)
'HERE I CANNOT DESERIALIZE THE DATAEXCHANGE CLASS
Dim ds As DataExchange = ClsMisc.DeSerializeBinary(
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
ok i found a turn-around to get all data but here is my problem :
i describe the steps for the server :
create a new dataset with some data inside
create an instance of dataExchange (which is serializable)
serialize dataexchange with binary formatter into a memory stream
convert the memorystream into base64 string
send this string to the client
client side :
receive all the data into byte array
use memory stream to read the byte array => here is the problem, i always have a "0" byte readed!
deserialize back the string into dataexchange object
... do something with the dataExchange
where i have the problem i double check the base 64 send from the server and received from the client, they are exactly the same (i used winMerge to do this)
please help, i don't know what to do...
Regards
Business Accounts
Answer for Membership
by: apeterPosted on 2008-06-12 at 08:17:42ID: 21770432
Either you should know how many bytes you are sending ahead or you should have a mechanism of endding all messsges with a custom character you are sending and in the server side you should read the stream untill you read your "custom end character".
Else instead of custom end character send the length first and then send all your data. Server should read this length first and then read the bytes untill you get the total length.