Why is VPN client truncating socket data ~ 1300 bytes?

Unanswered Question
Jul 11th, 2012

Using Cisco VPN Client Release 4.8.02.0030 for Linux on Centos 5.

Locally I have a C application that accepts socket requests and sends data.

On the remote server farm in the DMZ is a php page that asks the socket on the local machine for data over the socket.

It gets around 1300 bytes out of the 4500 or so bytes and errs out:

function.socket-read</a>]: unable to read from socket [104]: Connection reset by peer

The identical application running on a server inside the remote server  farm sends the full 4500 bytes or so of data to the php application.

I also wrote a trivial C client for the application to see if it was a  php issue. It works from the  local host to the local application, but  not from any remote host on the server farm to the local application.

I uploaded the c file, and it is also below.

(EDIT) I also uploaded the php client code (client.php) and pasted it below as well.

The php client gets fewer characters returned, not sure why


Thus it appears that the VPN Client is truncating the data, possibly at the MTU boundary.

The basic issue:
remote host->remote application - OK
remote host->local application (via vpnclient) - Truncates data

Please note that I have tried read and write in addition to send/recv on the socket with identical results.

Any ideas on how to get around this would be appreciated.

The php client code:

<?php

   // Create a TCP/IP Socket

   $socket = socket_create (AF_INET, SOCK_STREAM, 0);

   if ($socket < 0) { echo "socket() failed: reason: " . strerror ($socket) . "\n"; }

   // Connect to Target

   $result = socket_connect ($socket, $address, $service_port);

   if ($result < 0) { echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n"; }

   // Send Input Transaction

   socket_write ($socket, $outPost, strlen ($outPost));

   // Read Output Transaction

   //get length of response

   $tmp = socket_read ($socket, 6, PHP_NORMAL_READ);

   $slen = (int)($tmp-6);

   $out = (string)$tmp;

   //get response

   while(($sting = socket_read($socket, $slen)) !== false) {

        $out = $out.$sting;

        if(strlen($out) >= $slen) break;

//        if(strlen($out) >= ($slen-6)) break;

   }

   return $out."\n";

   // Close Socket

   socket_close ($socket);

?>

The c client code:

//file client.c

//simple socket client

#include <sys/socket.h>

#include <netinet/in.h>

...

#define PORTNUMBER 1528

int main(void){

//some declarations

...

struct hostent *hp;

struct sockaddr_in name;

...

//host

        sprintf(hostname, "somehostname");

        hp = gethostbyname(hostname));

        s = socket(AF_INET, SOCK_STREAM, 0);

        //Create the address of the server.

        memset(&name, 0, sizeof(struct sockaddr_in));

        name.sin_family = AF_INET;

        name.sin_port = htons(PORTNUMBER);

        memcpy(&name.sin_addr, hp->h_addr_list[0], hp->h_length);

        len = sizeof(struct sockaddr_in);

        connect(s, (struct sockaddr *) &name, len);

//send a request

        nbytes = send(s, msg, n, 0); //some request

        nflags = 0;

        //get the message length

        nbytes = recv(s, msgout, 6, nflags);

printf("msg from socket\n%s", msgout);

        n = atoi(msgout);

        //get the message

        nbytes = recv(s, msgout, n, nflags); //nbytes around 4500 bytes

printf("msg from socket\n%s", msgout);

    close(s);

    exit(0);

}//end main

Edit: I uploaded the php request - file client.php and pasted it into the text

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Average Rating: 0 (0 ratings)

Actions

Login or Register to take actions

This Discussion

Posted July 11, 2012 at 11:02 AM
Stats:
Replies:0 Avg. Rating:
Views:581 Votes:0
Shares:0

Related Content

Discussions Leaderboard