Connecting to the server

I am connecting to the server, after I have made the connection, the server should send the command HAAAPSI GhDfhhAs 7and I should respond to it (HAAAPSIis generated all the time, i.e. e. GhDfhhAs 7are generated characters).

Here is a snippet from the code:

<?php
  // 
  $nick = 'vova';
  $name = 'vova';
  $test = '123';
  $serv = '***************';
  $port = 6667;
  $chan = 'uid';
  //     =)
  set_time_limit(0);
  //  
  $socket = fsockopen($serv, $port) or die();
  //  ,     HAAAPSI ........ .
  //  ,   -   :
  fputs($socket,"USER $name\n"); 
  fputs($socket,"NICK $nick\n"); 
  fputs($socket,"PRIVMSG $test\n");

Answer 1, authority 100%

$socket = fsockopen($serv, $port) or die();
$ans = fgets($socket); // $ans -   
die(var_dump($ans));