Loading SDL_Surface across a network

Hi

I have a client/server setup working using SDL_Net - works great !! Now I
would like to copy binary data from the server to the client, for doing
things like ensuring the client has the latest version of graphics and game
data.

I have a few questions I hope you can help me with.

Whats the largest size file you can throw at SDL_Net ? Does the underlying
TCP stack break the file into packets and then reassemble them at the other
end, or will I need to break the file up myself and send it bit by bit ? And
if so, whats the largest size packet I can use ?

For copying a SDL_Surface across the network, I thought I could just send
the pixel data to the client and then use SDL_CreateRGBSurfaceFrom to create
a ‘local’ SDL_Surface. How do I work out the size of the pixel data ? Is it
height x width x depth ?

Thanks for any help
David.—
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.286 / Virus Database: 152 - Release Date: 10/9/2001


IMPORTANT: This e-mail, including any attachments, may contain private or
confidential information. If you think you may not be the intended
recipient, or if you have received this e-mail in error, please contact the
sender immediately and delete all copies of this e-mail. If you are not the
intended recipient, you must not reproduce any part of this e-mail or
disclose its contents to any other party.


Hi

I have a client/server setup working using SDL_Net - works great !! Now
I would like to copy binary data from the server to the client, for
doing things like ensuring the client has the latest version of
graphics and game data.

I have a few questions I hope you can help me with.

Whats the largest size file you can throw at SDL_Net ? Does the
underlying TCP stack break the file into packets and then reassemble
them at the other end, or will I need to break the file up myself and
send it bit by bit ? And if so, whats the largest size packet I can use
?

I haven’t studied the code closely, but I wouldn’t expect SDL_net to do
much about this. If that’s the case, this stuff depends entirely on the
underlying protocol implementation.

If the communication is done using read()/write(), over a streaming
connection, things should work just as with a fifo, “perfect” serial line
or whatever - if your buffer is too large, write() will block, and
transfer it piece by piece. (Unless you’ve opened in non-blocking mode,
that is…)

If send()/recv() is used, atomic packets are required, and there is a
size limit - probably a rather restrictive one, at that.

For copying a SDL_Surface across the network, I thought I could just
send the pixel data to the client and then use SDL_CreateRGBSurfaceFrom
to create a ‘local’ SDL_Surface. How do I work out the size of the
pixel data ? Is it height x width x depth ?

It should be for software surfaces, but it might still be a good idea to
include the pitch in the calculations, rather than assuming that it
equals width * BytesPerPixel.

And you should probably encode the bitmasks and stuff from the
PixelFormat struct as well. Color channel order may differ between file
formats, and possibly also CPU endian. In fact, things probably won’t
work at all without that info, if you pass data between different endian
CPUs. (The PixelFormat info assumes that you read/write data in the
"natural" way for the CPU for the actual the BytesPerPixel. That’s why
you have to #ifdef for endian when generating sufaces for OpenGL, BTW -
what looks the same to an x86 and a PPC in the registers, is different in
RAM.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 17 October 2001 01:36, Berry, David wrote:

“Berry, David” <David.Berry at dcita.gov.au> wrote:

For copying a SDL_Surface across the network, I thought I could just send
the pixel data to the client and then use SDL_CreateRGBSurfaceFrom to create
a ‘local’ SDL_Surface. How do I work out the size of the pixel data ? Is it
height x width x depth ?

pixel_data_in_bytes = img->h * img->pitch

note that you may need to byte-swap the pixels if the machines have different
byte order (or maybe reverse the RGB masks, but that is not always possible)