473,786 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Transfering Complex datastructures using Sockets

I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...

Jun 28 '06 #1
7 1446
sa****@gmail.co m (in
11************* *********@y41g2 00...legr oups.com) said:

| I need the explanation/code to transmit a complex datastructure like
| Linked list or binary tree
| using sockets from client to sever...

Not terribly difficult - just decide how you plan to parse the list or
tree, what (symbolic?)repr esentation makes sense for the pointers and
the specifics of your protocol for passing a single element. Once
that's done, all you need to do is write the code to implement what
you've specified.

If you have difficulties with the C coding part of the problem, look
for help here. :-)

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
Jun 28 '06 #2
sa****@gmail.co m wrote:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


<Off-topic>
In the general case, transfer the elements individually and rebuild
the data structure in the receiving end.
(There may be shortcuts in some particular scenarios.)
Try posting again in comp.programmin g
</Off-topic>
Jun 28 '06 #3
sa****@gmail.co m wrote:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


Then write serialisers and deserialisers and read up on the socket
implementation for your platforms of interest. Alternatively, use a
language that has all this built in.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jun 28 '06 #4

sa****@gmail.co m wrote:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


Use sprintf() and store into a character array and transfer through
sockets.
Do the reverse in the receiving side.

That what i'm doing to avoid big-endian and little endian problems.

Jun 28 '06 #5

deepak wrote:
sa****@gmail.co m wrote:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


Use sprintf() and store into a character array and transfer through
sockets.
Do the reverse in the receiving side.

That what i'm doing to avoid big-endian and little endian problems.


what about if the two machines don't use your character encoding?

Hint: this is why things like ASN.1 were invented.

Tom

Jun 28 '06 #6
"deepak" <de*********@gm ail.com> writes:
sa****@gmail.co m wrote:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


Use sprintf() and store into a character array and transfer through
sockets.
Do the reverse in the receiving side.

That what i'm doing to avoid big-endian and little endian problems.


Linked lists and binary trees include pointers. Pointers can be
converted to strings with sprintf, and back again with sscanf, but the
values will be meaningless on the receiving side. In the general
case, you'll need to map pointer values to some kind of index, then
allocate the individual nodes on the other end and re-map the indexes
back to pointers.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 28 '06 #7
sa****@gmail.co m writes:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...


If you find a way to serialize and deserialize the information
contained in the nodes then you can use either XML or, easier to use,
LISP syntax to send the information along with the structure.

A
/ \
B C
/ \ / \
D E F G

The above structure can be sent as:

(A (B (D E)) (C (F G)))

You can run into problems if you have ( and ) as part of the
information in the nodes. If you escape those characters or if you
encode all the information in the nodes to use printable characters
except for '(' and ')' in a specific encoding you should be safe and
have an almost portable protocol.
Check uuencode and uudecode for hints.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Jun 29 '06 #8

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

Similar topics

0
1223
by: Bram Stolk | last post by:
Hello, Python features the Queue.Queue object that provides thread-safe access. What if I want thread access to other types of datastructures? Would I need to pair e.g. each list, Set or hashmap with its own threading.Semaphore() object? Or is there an easier way to have thread-safe access to datastructures?
2
373
by: Mark G. Zeringue | last post by:
Which newgroup wouldbe best for questions about using sockets in dot net? Thanks Mark
7
1538
by: Ravi J | last post by:
What is the best way to transfer files between two .NET executables? I have a service, and a client program. Client asks service for data. The service creates one, and passes it back to client. Both programs run in .NET framework. Given this requirement, how best to approach the issue? Does .NET framework provides any class that can help? Thanks in advance,
1
1748
by: Michael Shestero | last post by:
Hello. General description of my knotty problem: I have a code (a function f) on standart C++ that perform some smart action. This code works as console application getting user input from fstream and putting output to another fstream. So, I can make easy console-application with void main(void) { f(&cin, &cout); }. This function f(...) works well. but it is very complex and it uses 'in' and 'out' in many places. It also sends them in...
5
1347
by: Daniel Fudge | last post by:
I'm trying to call an executable and read an object from it. For sake of simplicity say it's just the double "x". In my Read_Object.exe code I can call the program with the following. i = system ("Build_Object.exe"); Build_Object.exe creates an object that I require in the parent program, Read_Object.exe. Is there a method to communicate between child and parent? If so, can you point me to it? Currently, I'm communicating via a
0
2526
by: olafmol | last post by:
Hello, i have a problem using a .NET WSDL Webservice from PHP. Using both the NuSOAP lib for PHP4, and the build-in SOAP lib for PHP5 it seems that the SOAP client cannot pass a variable amount of complex datatypes to the WSDL webservice. This is the request-structure we've been using: <EzCreateAuctionArray xmlns=http://www.blabla.com>
1
1039
by: Dzemo | last post by:
Is there any way to transfer picture files between two computers on LAN. Do I need to use sockets or... Any ideas or examples THX
5
2277
by: Pilence | last post by:
Hy!! Can someone tell me please how to do this type of work done by using C#......
2
1237
by: mohi | last post by:
hello every one , i know this is a c++ forum ,but as i cudn't get any datastructures forum ..iam posting here : can anyone tell me which is the best language to be used for implementation of datastructures by best i mean speed of operation : and if given a choise that someone knows both c and c++ which one will be convinent ang faster for implementimg data structures??
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9960
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.