I'm trying to write an helper class that allows me to serialize objects to a
socket (or a NetworkStream). I know there are plenty of .NET classes that
help me to serialize object to an array of byte, but I can't undestand how I
can send a block of bytes and being sure the receiver will receive only this
block....I mean, if I write the bytes to a NetworkStream the receiver will
get a stream of bytes and he won't have any way to know how to "split" the
data. Am I supposed to build a protocol, using a special byte to mark the
beginning and the end of every "message" (in this case I should stuff the
bytes before sending)?
I hope I've explained well what I would like to do
Thank you for your help
Seba 5 1546
well, you could if you want to.
but I think you might be interested by remoting !!
which is the .NET RPC mechanism......
"cold" <co****@libero.it> wrote in message
news:e1**************@TK2MSFTNGP14.phx.gbl... I'm trying to write an helper class that allows me to serialize objects to a socket (or a NetworkStream). I know there are plenty of .NET classes that help me to serialize object to an array of byte, but I can't undestand how I can send a block of bytes and being sure the receiver will receive only this block....I mean, if I write the bytes to a NetworkStream the receiver will get a stream of bytes and he won't have any way to know how to "split" the data. Am I supposed to build a protocol, using a special byte to mark the beginning and the end of every "message" (in this case I should stuff the bytes before sending)?
I hope I've explained well what I would like to do
Thank you for your help
Seba
You can use either:
- fixed-size messages
- variable-size messages with the size in each message
- a special separator at the end of each message.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers: http://www.mztools.com
"cold" <co****@libero.it> escribió en el mensaje
news:e1**************@TK2MSFTNGP14.phx.gbl... I'm trying to write an helper class that allows me to serialize objects to a socket (or a NetworkStream). I know there are plenty of .NET classes that help me to serialize object to an array of byte, but I can't undestand how I can send a block of bytes and being sure the receiver will receive only this block....I mean, if I write the bytes to a NetworkStream the receiver will get a stream of bytes and he won't have any way to know how to "split" the data. Am I supposed to build a protocol, using a special byte to mark the beginning and the end of every "message" (in this case I should stuff the bytes before sending)?
I hope I've explained well what I would like to do
Thank you for your help
Seba
And which separator can I use? I mean, I can't be sure the character I'll
use won't be present in the content of the stream of bytes I'm sending. I
suppose I have to stuff the bytes...any suggestion?
thanks
Seba
"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> ha scritto nel
messaggio news:%2****************@TK2MSFTNGP09.phx.gbl... You can use either:
- fixed-size messages - variable-size messages with the size in each message - a special separator at the end of each message.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA You can code, design and document much faster. Free resources for add-in developers: http://www.mztools.com
"cold" <co****@libero.it> escribió en el mensaje news:e1**************@TK2MSFTNGP14.phx.gbl... I'm trying to write an helper class that allows me to serialize objects to a socket (or a NetworkStream). I know there are plenty of .NET classes that help me to serialize object to an array of byte, but I can't undestand how I can send a block of bytes and being sure the receiver will receive only this block....I mean, if I write the bytes to a NetworkStream the receiver will get a stream of bytes and he won't have any way to know how to "split" the data. Am I supposed to build a protocol, using a special byte to mark the beginning and the end of every "message" (in this case I should stuff the bytes before sending)?
I hope I've explained well what I would like to do
Thank you for your help
Seba
For binary messages there is no safe separator. For text messages, you can
use some sequence of characters that are not part of your protocol.
In general, it's better to include the size in the message header. It will
perform better than checking each byte to find separators...
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers: http://www.mztools.com
"cold" <co****@libero.it> escribió en el mensaje
news:%2***************@TK2MSFTNGP09.phx.gbl... And which separator can I use? I mean, I can't be sure the character I'll use won't be present in the content of the stream of bytes I'm sending. I suppose I have to stuff the bytes...any suggestion?
thanks
Seba
you obviously has to pass the size of the date first, in the message header
so you should serialize to a MemoryStream first, get the byt array, then
construct you message with a simple header, I would say
MSG:
| MSG type (1 byte) | MSG size (4 bytes) | MSG data (your serialized object,
"n" bytes specified in size) |
but why not use remoting?
it's a perfect high level, object oriented, .NET specific, interprocess
communication protocol/tool
"cold" <co****@libero.it> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... And which separator can I use? I mean, I can't be sure the character I'll use won't be present in the content of the stream of bytes I'm sending. I suppose I have to stuff the bytes...any suggestion?
thanks
Seba
"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> ha scritto nel messaggio news:%2****************@TK2MSFTNGP09.phx.gbl... You can use either:
- fixed-size messages - variable-size messages with the size in each message - a special separator at the end of each message.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA You can code, design and document much faster. Free resources for add-in developers: http://www.mztools.com
"cold" <co****@libero.it> escribió en el mensaje news:e1**************@TK2MSFTNGP14.phx.gbl... I'm trying to write an helper class that allows me to serialize objects to a socket (or a NetworkStream). I know there are plenty of .NET classes that help me to serialize object to an array of byte, but I can't undestand how I can send a block of bytes and being sure the receiver will receive only this block....I mean, if I write the bytes to a NetworkStream the receiver will get a stream of bytes and he won't have any way to know how to "split" the data. Am I supposed to build a protocol, using a special byte to mark the beginning and the end of every "message" (in this case I should stuff the bytes before sending)?
I hope I've explained well what I would like to do
Thank you for your help
Seba
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan |
last post by:
Hello
Has anybody tried to open a socket to connect to a server on page a.php
and then passing it throung a session variable and getting it back at
page b.php and use it there.
Ive tried that...
|
by: Mike M |
last post by:
Is it possible? In the parent process, I have a socket that binds,
listens and then accepts new connections (which creates new sockets in
the process). I want to be able to pass some of these new...
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: Scott Zabolotzky |
last post by:
I'm trying to pass a custom object back and forth between forms.
This custom object is pulled into the app using an external reference
to an assembly DLL that was given to me by a co-worker. A...
|
by: Michael Isaacs |
last post by:
Is there any way to share an object or variable between applications other
than through .NET remoting? Also, if this is the only way, what kind of
overhead is there for storage (memory) and speed...
|
by: cold |
last post by:
I'm trying to write an helper class that allows me to serialize objects to a
socket (or a NetworkStream). I know there are plenty of .NET classes that
help me to serialize object to an array of...
|
by: manochavishal |
last post by:
Hi,
I am having strange problem in my Program.
I cannot paste the whole program as it is huge so just pasting the
lines i think are necessary.
I am passing a integer array pointer to a...
|
by: martin |
last post by:
This code compiles (this is how it should work):
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
This code does not compile (passing an int instead of...
|
by: william.w.oneill |
last post by:
I have an application that takes a few command line parameters. As
recommended by others in this group, I'm using a named mutex to ensure
that only one instance of the application is running. My...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |