Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Socket Programming

by duff (Vicar)
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.


Comment on Re: Socket Programming
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.

      sth

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://319373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2014-09-19 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (142 votes), past polls