I have very strange problem...
I've written a script that uses REST::Client module to run tests over HTTP.
Its working fine besides against one particular java application with embedded tomcat(on Linux)
When REST Client opens tcp socket, the server immediately aborts it (SYN->SYN,ACK->ACK and then FYN,ACK from server),
As a result of closing connection by server, LWP module prints "500 Server closed connection without sending any data back".
The java application is a production one and dont make any problem when accessed from another applications or web ui.

I found some old script on the system that opens socket successfully, the script implements socket directly:

$AF_INET = 2; $SOCK_STREAM = 1; $sockaddr = 'S n a4 x8'; $this = pack($sockaddr, $AF_INET, 0, $thisaddr); $that = pack($sockaddr, $AF_INET, $port, $thataddr); ($name,$aliases,$proto) = getprotobyname('tcp'); socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!"; bind(S, $this) || die "bind: $!"; if (connect(S, $that)) { print connetced } select(S); $| = 1; select(STDOUT); print S "$USER_VALUE CHECK $host\n";

I debugged REST and underlying modules and saw that parameter passed to socket are similar (besides $sockaddr = 'S n a4 x8' which I didnt understand..)
What is the problem here ?


In reply to strange problem with opening tcp socket by gdanenb

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.