Re: sending structure client server
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Sun, 12 Oct 2008 13:57:27 +0200
s0suk3@xxxxxxxxx writes:
On Oct 11, 4:47 pm, Alex Fraser <me@xxxxxxxxxxx> wrote:
Ian Collins wrote:
s0suk3@xxxxxxxxx wrote:
On Oct 11, 11:19 am, swetha <laptop545@xxxxxxxxx> wrote:
Hi ,
I want to send a structure (user defined) for example :
struct bank{
int empid;
char name[50];
float amount;
} per;
[...]
The code you posted will only work on a homogeneous network. If either
the client or sever have a different representation of the struct, all
bets are off.
And the solution is to turn the data into a stream of bytes (at the
sender) and back again (at the receiver), according to some protocol.
This is similar to defining a file format.
[...]
One real solution to the whole problem would be what Andrew Gabriel
suggested. A better solution, IMO, would be to create a protocol
designed specifically for the needs of your app, or to use an existing
one, such as HTTP, perhaps by extending it. You could then transmit
the data as either text (in the headers of the message, for example),
or as binary (in the body of the message). Of course, sending it as
binary would lead us back to the same problem: struct
representation.
IOW, 'using HTTP' by itself would add nothing specifically helpful
regarding the problem of 'data transmission' between (potentially)
heterogenous computing environments (while 'using XDR-encoding'
would). That's because HTTP is an application protocol designed to
communicate meta-information necessary to build distributed
hypermedia-systems, eg by providing a 'device-independent' way to
specify a particulary named 'ressource' and some operation supposed
to be done with it (for instance, GET or PUT it). The 'how everyone
else does it' approach to constructing any server application would be
'use a programmable HTTP-server' and send documents conforming to some
application-specific XML DTD and the 'first level workaround' for the
problem that
<sentence><subject><markup-language>XML</markup-language></subject><verb><thhird-person-singular>contains</third-person-singular></verb><quantifier><colloquial>lots
of</colloquial></quantifier><object><disposable>trash</disposable></object><dot>.</dot></sentence>
would be to make the communicating computers spend even more time with
communication meta-processing by compressing and decompressing the
message in order to temporarily get rid of at least some of the
redundant information added by the encoder.
It is ususally easier to just define a binary message format and use
encoding and decoding routines to convert it to/from some 'native
representation' a program can easily deal with (I have just designed a
specific binary data format for exchanging data sets composed of
sequences of records with members of specific types and the written
specification of the data format plus the (C-)code which decodes the
transport format into linked C structs contains less text than the
introductory remarks of the XML-specification [slight hyperbole :->]).
A general tip for anything like this would be "include a way to
distinguish between multiple revisions/ versions of the protocol, so
that a 'newer' server can offer other/ additional features to 'new'
clients while still being able to serve old clients".
.
- Follow-Ups:
- Re: sending structure client server
- From: James Kanze
- Re: sending structure client server
- References:
- sending structure client server
- From: swetha
- Re: sending structure client server
- From: s0suk3
- Re: sending structure client server
- From: Ian Collins
- Re: sending structure client server
- From: Alex Fraser
- Re: sending structure client server
- From: s0suk3
- sending structure client server
- Prev by Date: Re: sending structure client server
- Next by Date: Re: sending structure client server
- Previous by thread: Re: sending structure client server
- Next by thread: Re: sending structure client server
- Index(es):
Relevant Pages
|
Loading