Jump to content

Help with code!


Pro.Luv

Recommended Posts

Hi,

 

I need help with this code it does work I need to know how I can send back data from the server.php to the client.php..

 

Client.php

  /* Open a socket to port 1234 on localhost */
    $socket = stream_socket_client('tcp://127.0.0.1:1234');
    
    /* Send more data out of band. */
    stream_socket_sendto($socket, "This Data", STREAM_OOB);
    
    /* Close it up */
    fclose($socket);

 

 

Server.php

  // Open a server socket to port 1234 on localhost
   $server = stream_socket_server('tcp://127.0.0.1:1234');

   // Accept a connection
   $socket = stream_socket_accept($server);
   echo "Waiting for data from client...";

   // Output recieved data
   $data = stream_socket_recvfrom($socket, 1500);
   echo "Data: ".$data."\n";

   //do something here then send results back.

   // Close it up
   fclose($socket);
   fclose($server);

 

The client sends This Data to the server and the server retrieves it... I need to know what must I add to the server.php to send back data ?

 

In server.php:

I want to take the data being sent from the client.php and search it in the database then send back results to the client for displaying.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/174155-help-with-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.