473,394 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sending additional info with byte array with sockets

Hello,

I want to send an additional info with byte array wiith sockets as "one
packet".
I know how to send the byte array by himself, but how can I send the
additional info with it at the same time (as one packet)?

thx for yout answers.
Nov 17 '05 #1
4 1693
TomHL <To***@discussions.microsoft.com> wrote:
I want to send an additional info with byte array wiith sockets as "one
packet".
I know how to send the byte array by himself, but how can I send the
additional info with it at the same time (as one packet)?

thx for yout answers.


Firstly, you can't guarantee that information you send on a socket will
be sent in a single packet, and you shouldn't rely on it. Sockets give
*streams* of data, and that's how the information should be thought of.

Now, as to sending "additional information" - that will have to be part
of the data sent. You could, for instance, have a sort of "header"
section before the data, potentially including the length of the data
as well as other bits of information. It will be part of the data
received, however, so the other end will need to know that there'll be
that header section first.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Hi Jon, thx for your answer.
How do I cretae and send the Header with the byte array (don't forget that I
need to send it attached to the byte array :-))?

"Jon Skeet [C# MVP]" wrote:
TomHL <To***@discussions.microsoft.com> wrote:
I want to send an additional info with byte array wiith sockets as "one
packet".
I know how to send the byte array by himself, but how can I send the
additional info with it at the same time (as one packet)?

thx for yout answers.


Firstly, you can't guarantee that information you send on a socket will
be sent in a single packet, and you shouldn't rely on it. Sockets give
*streams* of data, and that's how the information should be thought of.

Now, as to sending "additional information" - that will have to be part
of the data sent. You could, for instance, have a sort of "header"
section before the data, potentially including the length of the data
as well as other bits of information. It will be part of the data
received, however, so the other end will need to know that there'll be
that header section first.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3
TomHL <To***@discussions.microsoft.com> wrote:
Hi Jon, thx for your answer.
How do I cretae and send the Header with the byte array (don't forget that I
need to send it attached to the byte array :-))?


You don't need to send it "attached" to the byte array. Just send the
header (as a byte array), then send the byte array itself. Don't forget
it's just a stream of data when all is said and done.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
thx.

"Jon Skeet [C# MVP]" wrote:
TomHL <To***@discussions.microsoft.com> wrote:
Hi Jon, thx for your answer.
How do I cretae and send the Header with the byte array (don't forget that I
need to send it attached to the byte array :-))?


You don't need to send it "attached" to the byte array. Just send the
header (as a byte array), then send the byte array itself. Don't forget
it's just a stream of data when all is said and done.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bob Garbados | last post by:
I need to construct an xml document, send it to a service over tcp/ip to a specified port, receive the xml response, and process the xml response. I can create the xml document to send, but what's...
4
by: Abubakar | last post by:
Hi, I am writing a server in C# and client in C++ (pure, not managed). The communication goes on through sockets. In C# I am using NetworkStream to send text data (by converting it to byte array)...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.