Re: sending structure client server



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".




.



Relevant Pages

  • Re: Can Word/Excel 2004 and Word/Excel 2008 be on same machine?
    ... Those things are worth having to my clients :-) ... use, and, most importantly to us, the PDF format is a fully-governmental ... If you get a PDF version, ... Microsoft to make substantial changes to its core products, ...
    (microsoft.public.mac.office.word)
  • Re: Tech question - interface between receiver and central station software
    ... I agree with the benefits of being local - ADT is losing a lot of clients ... > remote terminal we monitor for another company, ... > We have a few IRFast clients, very handy format. ... >> Patriot guy, who asked us more question than we asked him. ...
    (alt.security.alarms)
  • Re: 9bit arithmetics in C
    ... It may not, however, be a close enough for the emulation required to ... I need to know that exact binary representation of values within ... because of endian-ness or number format). ... I will define "internal format" as the normal C types which are actually ...
    (comp.lang.c)
  • Re: Time Accuracy
    ... seconds is no less "reliable" than the representation of 0.1 seconds, ... theoretically be handled by the available decimals. ... the format of the time component is just 5 decimal fractions. ... numeric format to 15 significant digits is 39890.5031526620. ...
    (microsoft.public.excel.misc)
  • Re: breadboarding fast, tiny stuff
    ... The TDR of the gate indicates that the gate ... The zip format is widely used in industry. ... Lets see, tgz, bz, tar, and lha come to mind promptly. ... I've got a lot of clients yet the number of clients I ...
    (sci.electronics.design)

Loading