Well, unfortunately, the IO::Socket hides all the details of what I'm about to say, but you can take a look at the low level socket stuff in the Camel book or the perlfunc man page.

What's happening is that when you establish a connection with IO::Socket, the first thing it does is make a call to 'socket', which opens a socket and attaches it to a filehandle. This is equivalent to a 'open' call on a standard file. It then calls 'connect', which establishes a TCP connection with the remote host.

Now, when you're finished with the socket and you need to close it down, you should call shutdown, as this informs the TCP stack that you'd like to terminate the session nicely. Unfortunately, this only deals with TCP - you still need to break the relationship between the socket and the file handle, which is done with 'close', as it is with any file handle...

If you're looking for more details on how the underlying calls work, the best book I've ever seen is Unix Network Programming, by W. Richard Stevens. It's all related to C programming, but maps quite nicely onto low-level Perl calls (although you should be using IO::Socket).


In reply to Re: shutdown vs. close on INET sockets by ozone
in thread shutdown vs. close on INET sockets by gomez18

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.