Home: Perl Programming Help: Intermediate:
strange problem with opening tcp socket



gdan2000
Novice

Dec 24, 2011, 8:50 AM


Views: 1729
strange problem with opening tcp socket

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:

Code
$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 ?


(This post was edited by gdan2000 on Dec 24, 2011, 9:40 AM)