Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks for the reply tachyon (and pg). I'm using Perl v5.6.1 build 631 on Win32. I'm also using Socket for TCP. I do have output autoflush on. I have it set at the top of the script $|=1; and I have select((select($socket), $|=1)[0]);

I tried all combinations of TCP_NODELAY and SO_LINGER but I still didn't get consistent results. Printing to the socket seems to work intermittently when I use those options or when I use no options at all.

If I call shutdown with 0, 1 or 2 and follow it with a close the msg doesn't get delivered. If I get rid of the close and just call shutdown with a 1 or 2 the msg doesn't get delivered. If I call shutdown($socket, 0) without a following close then the msg does get delivered.

I found the Socket FAQ to be an excellent resource. Thanks for the link. I found this part especially good. "Nagle's algorithm collects small packets together (no more than .2sec delay) and thereby reduces the amount of overhead bytes being transferred.". This is why the sleep 1; before the close worked. Even though I specified TCP_NODELAY, it appears that it is still buffering.

I write to the socket like this print $socket (pack("N", length($msg)), $msg); What would a similar syswrite look like? I can't seem to get syswrite to work at all. Syswrite will be my last test before I try and post some code. The sever is written in C++ so I'll have to try and emulate it and I'm not sure I'll have the same results in Perl.

Thanks again everyone.


In reply to Re^2: connect() & close() by monktim
in thread connect() & close() by monktim

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found