473,394 Members | 1,843 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.

Structures question.

Hi,

I'm deveoping a Client/Server application.
I want to send information by using structures.
I want to have a standard header structure, and variable lenght
data.
for example,
---------------------------------------
public struct Header
{
public int sequenceNumber;
public int serviceRequest ;
----
----
}

public struct Info
{
Header head;
byte[] data;
}
-------------------------------
How do we marshal "Info" structure with variable byte[] data.
Currently I'm marshalling in the following way,

[MarshalAs( UnmanagedType.ByValArray, SizeConst= 1024)]
byte[] data;

but as the data should be of variable length, how can we marshal the byte[]
without specifying the size of the byte[]. I mean is there any way that we
can
find the size of the byte[] just before marshalling the sturcture "Info".

Kindly let me know,

Cheers,

Naveen.
Nov 16 '05 #1
6 1008
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?= <Na************@discussions.microsoft.com>
wrote in news:11**********************************@microsof t.com:
I'm deveoping a Client/Server application.
I want to send information by using structures.


What connection methodology are you using? SOAP? TCP? Remoting?

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Nov 16 '05 #2
I'm using TCP/IP connection.
"Chad Z. Hower aka Kudzu" wrote:
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?= <Na************@discussions.microsoft.com>
wrote in news:11**********************************@microsof t.com:
I'm deveoping a Client/Server application.
I want to send information by using structures.


What connection methodology are you using? SOAP? TCP? Remoting?

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/

Nov 16 '05 #3
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
<Na************@discussions.microsoft.com> wrote in
news:85**********************************@microsof t.com:
I'm using TCP/IP connection.


Is there a reason you definitely want to write the structure? What about
using dataset structures and sending it over as XML?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #4
Honestly speaking, I don't know how to use Dataset structures and sending them
over as XML. Could you explain in some detail please.

Actually, I'm developing a Class library(Dll) that helps Client/Server
applications.

"Chad Z. Hower aka Kudzu" wrote:
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
<Na************@discussions.microsoft.com> wrote in
news:85**********************************@microsof t.com:
I'm using TCP/IP connection.


Is there a reason you definitely want to write the structure? What about
using dataset structures and sending it over as XML?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/

Nov 16 '05 #5
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
<Na************@discussions.microsoft.com> wrote in
news:B9**********************************@microsof t.com:
Honestly speaking, I don't know how to use Dataset structures and
sending them over as XML. Could you explain in some detail please.


A good way is to create a typed dataset. Try this article, its not exactly
what you need, but I think you'll quickly get the idea of how it applies to
your situation. Datatables also supports multiple rows altough this article
does not demonstrate this.

http://www.codeproject.com/dotnet/XMLSettingsFile.asp
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 16 '05 #6
If all you're trying is to send instances of objects over the wire, why
not serialize them and send them directly, instead of trying to marshal
yourself?

MemoryStream ms = new MemoryStream();
BinaryFormatter f = new BinaryFormatter();

f.Serialize(yourObject, ms);

byte []data = ms.ToArray();
socket.Write(data);

You can then do the reverse on the receiving side.

Regards
Senthil

Nov 16 '05 #7

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

Similar topics

11
by: Fred Bennett | last post by:
I have a simulation project in which data can naturally be held in structures for processing. There are calls to multiple functions involved. Execution speed is an issue. Do I take a big hit for...
1
by: kazack | last post by:
Hi all it's me again with another question as I got further in my book. The chapter I am in covers structres, abstract data and classes. I only read through to the end of the coverage on...
14
by: tweak | last post by:
I'm struggling with the concept of typecasting when setting up a TCP client. Here's a code snip (modified from W. Richard Stevens Unix Programming book) to demonstrate where I am struggling: ...
11
by: Alfonso Morra | last post by:
Hi, I have the ff data types : typedef enum { VAL_LONG , VAL_DOUBLE , VAL_STRING , VAL_DATASET }ValueTypeEnum ;
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
11
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure...
44
by: svata | last post by:
Hello, I wonder how to resize such array of structures using realloc()? #include <stdio.h> #include <stdlib.h> #define FIRST 7 typedef struct { char *name;
29
by: Mik0b0 | last post by:
Hallo to everyone. This fall I am going to start data structures as a part of C language course. The problem is I could not find any satisfying tutorial about structures in C. There are plenty of...
8
by: Bob Altman | last post by:
Hi all, I have a structure that includes a constructor. I want to add a bunch of these structures to an STL map (whose index is an int). If I define the map like this: map<int,...
32
by: Paulo J. Matos | last post by:
Hi all, I am a Python beginner, reading through 2.6 tutorial. I am wondering where are structures? On the other hand, I think I might have the answer. Since Python focus on having one way to...
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
BarryA
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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.