473,563 Members | 2,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynaic array through sockets(network )

Hi all,

I have a doubt.
If I have 2 structures and one is parent of other , ie the child
structure is present in the parent one . And if the child structure is
declared as dynamic array in the parent , will it be possible to pass
the parent structure thru network using sockets onto other application
running on different system provided the API is known to both the
sender and the receiver.

For Ex:

struct Child
{
a: Int;
b: float;
}
struct parent
{
c : Int;
d : array of Child;(dynamic array)
}

If I make it static array, I will be able to pass it, but wat if it is
dynamic.

Thanks

Sep 13 '07 #1
4 2802
"Chandra" <tr*****@gmail. comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
Hi all,

I have a doubt.
If I have 2 structures and one is parent of other , ie the child
structure is present in the parent one . And if the child structure is
declared as dynamic array in the parent , will it be possible to pass
the parent structure thru network using sockets onto other application
running on different system provided the API is known to both the
sender and the receiver.

For Ex:

struct Child
{
a: Int;
b: float;
}
struct parent
{
c : Int;
d : array of Child;(dynamic array)
}

If I make it static array, I will be able to pass it, but wat if it is
dynamic.
You need to serialize it. Consider, when you send data over sockets the
size of the data needs to be known by the receiving end. For a structure it
would be the size of the structure, which is constant. However. Other data
that the structure points to is not constant. Consider attempting to pass a
std::string (or dynamic char array) over sockets. The receiving end needs
to know when to stop receiving the string.

A common way is to send the size of the data first followed by the data.
The receiving end then first receives the size of the string, then it knows
when the string is finished.

So, for your dynamic array, you would wend to tell the receiving end the
size of the dynamic data.

Please refer to the C++ FAQ chapter 36: Serialization and Unserialization .
http://www.parashift.com/c++-faq-lit...alization.html
Sep 13 '07 #2
Chandra wrote:
I have a doubt.
I think it's a question.
If I have 2 structures and one is parent of other , ie the child
structure is present in the parent one . And if the child structure is
declared as dynamic array in the parent , will it be possible to pass
the parent structure thru network using sockets onto other application
running on different system provided the API is known to both the
sender and the receiver.

For Ex:

struct Child
{
a: Int;
b: float;
}
struct parent
{
c : Int;
d : array of Child;(dynamic array)
}

If I make it static array, I will be able to pass it, but wat if it is
dynamic.
It is all possible, the only difference is *how* you "pass" it. And
since C++ does not define what a "socket" is, or how one is used, there
is no clear answer to your /question/ in C++ terms. However, you might
find reading about "serialisat ion" useful. www.google.com

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 13 '07 #3
Chandra wrote:
Hi all,

I have a doubt.
Please don't multi-post questions, pick a language and ask in the
appropriate group.

--
Ian Collins.
Sep 13 '07 #4
On Sep 13, 10:03 pm, Chandra <trip...@gmail. comwrote:
I have a doubt.
If I have 2 structures and one is parent of other , ie the child
structure is present in the parent one . And if the child structure is
declared as dynamic array in the parent , will it be possible to pass
the parent structure thru network using sockets onto other application
running on different system provided the API is known to both the
sender and the receiver.
You can't pass structures through a socket interface, period.
All you can pass are bytes (char or unsigned char). Everything
else has to be formatted in accordance with the protocol being
used.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Sep 14 '07 #5

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

Similar topics

3
1661
by: Manuel Hegemann | last post by:
Hallo, in meinem Schulprojekt, soll eine Datei, jedesmal wenn Sie aktualisiert wird auf nen FTP-Server oder für den Test auf nen Netzwerkserver gespeichert werden. Das Problem ist, dass ich noch nie mit sockets gearbeitet habe und nicht weiß wie ich das realisieren soll. das wenn aktualisiert etc. ist ja kein problem... es geht nur um die...
6
639
by: Eric | last post by:
Does anyone know of any GOOD network programming book(s) that are C# based, as well as any online tutorials and forums on network programming? Thanks
1
5404
by: gmiley | last post by:
I have looked around in System.Net{} and System.Net.Sockets{} namespaces, but cannot seem to find a collection, or method for obtaining an active connections collection. I guess I am basically looking for a way to produce similar output as what netstat would produce, but in a controled C# environment where those enumerated connections could...
3
1015
by: iwdu15 | last post by:
ok, ive been going at this for a couple months now and i cant figure it out. i have a program the connects asyn to another comp with te same program using TCP sockets. then i can send text back and forth, no problem. how can i send text with formatting, like different fonts, styles, colors etc. ive tried everything i casn think of but nothing...
9
4888
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 strReturnData As String = _ System.Text.Encoding.ASCII.GetString(receiveBytes)
3
3319
by: mislavb | last post by:
Can Dev-Cpp (Mingw) (under windows) compile network libraries: #include <unistd.h> #include <arpa/inet.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> and if yes, what do I have to do to do it?
2
4331
by: Dave Dean | last post by:
Hi all, I'm just starting out in sockets/network programming, and I have a very basic question...what are the 'security' implications of opening up a socket? For example, suppose I've written a simple chat server and chat client. The server opens a socket, listens on a port, and accepts incoming connections. The clients open a socket and...
1
2311
by: Gurur | last post by:
Hi all, I have a doubt. If I have 2 structures and one is parent of other , ie the child structure is present in the parent one . And if the child structure is declared as dynamic array in the parent , will it be possible to pass the parent structure thru network using sockets onto other application running on different system provided the...
1
20580
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but I don't see the error): "System.IO.IOException: Unable to read data from the transport connection:A blocking operation was interrupted by a call...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.