Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Socket Programming

by duff (Parson)
on Jan 07, 2004 at 05:26 UTC ( #319373=note: print w/replies, xml ) Need Help??

in reply to Socket Programming

1) What is a packet? When my program reads from the socket, does it read only one packet?

A "packet" is kind of one of those made-up terms that means whatever the user wants it to mean. In the realm of TCP/IP a "packet" is a sequence of bytes that contains a sequence number, source address, destination address, and some data. As far as socket programming goes, these things are well below the level of detail you usually have to worry about. However, a particular protocol (for instance)may use the term "packet" though and would probably be referring to an individual chunk of meaningful data that is sent over a socket.

2) If the perl application on the other end sends the words "hello" and "there" separately by using 2 separate print statements, will my progam receive both words at once ("hello there") when it reads the socket?

Actually it would receive "helloworld" or perhaps "h", "e", "l", "l", etc. (depending on how you're reading) if you sent "hello" then "world" in separate print statements, but yes that's how it works. Think of sockets like you would pipes; whatever you put in them on one end can be read on the other end in the same order that it was put in.

I'm sure there are better descriptions out there, but I don't have any references handy, sorry. Google for "unix network programming" though and you'll find the definitive reference.

Replies are listed 'Best First'.
Re: Re: Socket Programming
by astroboy (Chaplain) on Jan 07, 2004 at 17:19 UTC
    I highly recommend "Network Programming with Perl" by Lincoln Stein. It's one of my favourite Perl books of all time

      I highly recommend "Network Programming with Perl" by Lincoln Stein. It's one of my favourite Perl books of all time

      ...I second that recommendation, I can't recommend that book enough! It is one my favourite Perl Books as well.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://319373]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-04-25 13:26 GMT
Find Nodes?
    Voting Booth?