title: PHP fwrite( ) Function with a stream file opened client socket stream
body: <p>I have a docker file that runs a geographical database server, and the container is up and running, in my backend, I am trying to make a TCP socket connection with that server
  like below</p>
  <pre><code>class socketClient{
  
   private $_socket;
  
      /**
       * Constructor
       *
       * @param string $server e.g. &quot;localhost:6379&quot;
       */
      public function __construct($address, $port)
      {
          $this-&gt;_socket = stream_socket_client($address.':'.$port);
      }
  
  $cmd = &quot;A native query that will be sent to my geographical server&quot;;
  
  fwrite($this-&gt;_socket, $cmd); // writing my $cmd in the stream resource
  
  $line = fgets($this-&gt;_socket); // getting the stream resource that I wrote in
  
   stream resource @52
       timed_out: false
       blocked: true
       eof: false
       stream_type: &quot;tcp_socket/ssl&quot;
       mode: &quot;r+&quot;
       unread_bytes: 0
       seekable: false
       options: []
     } // the $socket
  }
  </code></pre>
  <p>the problem here is that I don't know where the <strong>fwrite()</strong> function writes my file does it create an actual file or does it write to the stream resource I don't know, when I try this on my local machine it works fine and the command sent to my database but after I moved to docker this line $line = fgets($this-&gt;_socket); returns a <strong>false</strong> which means there is no data has been written or some error happened, I am expecting the written command to the stream</p>