[comp.unix.questions] sockets and packets

psember@lynx.trl.OZ.AU (P Sember SNR) (06/05/91)

    If I am sending long files down a socket is it best to split the file into
    packets. What size and why for a sun4?

					Thank you


  Peter Sember                   p.sember@trl.oz.au
  Telecom Research Labs.         Phone: +61 3 541 6127
  P.O. 249 Clayton, 
  Victoria 3168
  Australia

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (06/06/91)

In article <1991Jun5.055501.6003@trl.oz.au>, psember@lynx.trl.OZ.AU (P Sember SNR) writes:

> If I am sending long files down a socket is it best to split the file
> into packets.

Is that a statement or a question?  (Usually when people phrase a
sentence as a question and end it with a period it's clear; in this
case it's not so clear - if you switch "is it" to "it is" it's no
longer phrased as a question.)

> What size and why for a sun4?

You don't say what system, you don't say what sort of socket, and you
don't say what's on the other end of the socket.  So I have to guess.

If the socket is a SOCK_STREAM (which is probably true in your case),
it generally doesn't matter; the implementation will break it up for
you.  There's no point in trying to second-guess it, because it has
access to information you don't that can affect the best way to break
it up.  The only case where you *need* to break it up is if you're
speaking to a daemon of some sort which sends stuff back every so
often; in this case you need to read the stuff being sent back or
there may be danger of deadlock.

If the socket is a SOCK_DGRAM, your attempt to write will generally
fail unless the amount of stuff you're writing is small enough.  If
you're using datagram sockets, though, you should already know that and
have a protocol design in hand which deals with all the hair necessary
to use the things and make them work.

If the socket is some other sort, I haven't a clue what's up.  The only
other sort of socket I can recall offhand is SOCK_RAW, and if you have
to ask questions like this you have no business messing with SOCK_RAW.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu