title: How to receive GPS data on Web server?
body: <p>Below is the code for a client server application for Web Server. This code is working fine i.e. first I will run server script which bind my server program to specified IP and port, after that when i run client script and connect to same IP and port, server will accept the connection and call <strong>subroutine_name</strong> subroutine in which I have created one random variable $zz and storing its data to database using <strong>test.php</strong>.
  This is working fine for this server client application, but when I'am trying to connect a <strong>GPS device(tk103)</strong> to the same running server script by configuring same IP and port, nothing happens. Means no connection is established between server script and GPS device.</p>
  
  <p>Please help me.</p>
  
  <p>This is my client script.  <strong>client.pl</strong></p>
  
  <pre><code>#!/usr/bin/perl
  use cPanelUserConfig;
  use strict;
  
  print "Content-Type: text/html \n\n";
  # auto-flush on socket
  $| = 1;
  use IO::Socket::INET;
  # create a connecting socket
  my $socket = new IO::Socket::INET (
      PeerHost =&gt; '199.79.62.103',
      PeerPort =&gt; '7784',
      Proto =&gt; 'tcp',
  );
  print "cannot connect to the server $!\n" unless $socket;
  print "connected to the server\n";
  
  # data to send to a server
  my $req = 'hello world';
  my $size = $socket-&gt;send($req);
  print "sent data of length $size\n";
  
  # notify server that request has been sent
  shutdown($socket, 1);
  
  # receive a response of up to 1024 characters from server
  my $response = "";
  $socket-&gt;recv($response, 1024);
  print "received response: $response\n";
  
  $socket-&gt;close();
  </code></pre>
  
  <p>This is my server script for PHP server. <strong>server.pl</strong></p>
  
  <pre><code>#!/usr/bin/perl
  use cPanelUserConfig;
  print "Content-Type: text/html \n\n";
  use warnings;
  
  
  use IO::Socket::INET;
  
  # auto-flush on socket
  $| = 1;
  
  # creating a listening socket
  my $socket = new IO::Socket::INET (
      LocalHost =&gt; '199.79.62.103',
      LocalPort =&gt; '7784',
      Proto =&gt; 'tcp',
      Listen =&gt; 5,
      Reuse =&gt; 1
  );
  print "cannot create socket $!\n" unless $socket;
  print "server waiting for client connection on port 7784\n";
  
  
  
  while(1)
  {
      # waiting for a new client connection
      my $client_socket = $socket-&gt;accept();
  
      # get information about a newly connected client
      my $client_address = $client_socket-&gt;peerhost();
      my $client_port = $client_socket-&gt;peerport();
      print "connection from $client_address:$client_port\n";
      subroutine_name();
  
  
  
      # read up to 1024 characters from the connected client
      my $data = "";
      $client_socket-&gt;recv($data, 1024);
      print "received data: $data\n";
  
  
  
  
  
  
      # write response data to the connected client
      $data = "ok mi";
      $client_socket-&gt;send($data);
  
      # notify client that response has been sent
      shutdown($client_socket, 1);
  }
  
  sub subroutine_name{
        my $filename = 'report.txt';
      open(my $fh, '&gt;', $filename) or die "Could not open file '$filename' $!";
      print $fh "My first report generated by perl\n";
      close $fh;
      print "done\n";
  
  
       $zz='hello world my world';
      my $url = "http://www.geekzgarage.com/gps/test.php?"
        . "ln=$zz";
      # print "$url\n";
      use LWP::Simple;
      my $content = get $url;
      die "Couldn't get $url" unless defined $content;
  
  
  
  }
  
  $socket-&gt;close();
  </code></pre>