I am creating a socket connection. what I want the server to do is print
a message so that when the client connects, it sees a message.. eg:
 
Msg>
 
But my code doesn't print that until it the server receives something
from the client..
 
Here is the code.. I tried using the send ( ) command but that didn't
work either. :-(
 
#!/usr/local/bin/perl -w
     2
     3  use Socket;
     4
     5  if (!@ARGV) {
     6  print "Script cannot be called with no Port Number.... doh!\n";
     7  } else {
     8  $server_port = $ARGV[0];
     9
    10  socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
    11
    12  setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1);
    13
    14  $my_addr = sockaddr_in($server_port, INADDR_ANY);
    15
    16  bind(SERVER, $my_addr) or die "couldnt bind";
    17  listen(SERVER, SOMAXCONN) or die "cant listen";
    18  my $data = "msg>\n";
    19  send (FH, "$data");
    20  select (FH);
    21  print "$data";
    22  while (accept(CLIENT, SERVER)) {
    23  *STDOUT = *CLIENT;
    24  $input = <CLIENT>;
    25  chomp $input;
    26  chop $input;
    27  system ("./scottscript $input");
    28  #open (OUTSTUFF, ">checkdis");
    29  #print OUTSTUFF $input;
    30  #close OUTSTUFF;
    31  }
    32  close(SERVER);
    33  }
 
Regards, 
Scott L Ryan
OneTel.Net ISP Engineer
 
 


Reply via email to