Hola otra vez,
Esta vez vengo con un problema que no me deja continuar...Tengo implementado un servidor socket y un cliente java, la conexión y todo funciona correctamente y el envió de datos y todo...El problema biene cuando deseo enviar una orden desde ajax al servidor para que este se lo envie al cliente. El archivo PHP que hace de rol de servidor lo tengo en el "namespace proyectodam\Lib;" es decir es una libreria mia que no es un controlador ni una clase.
Desde la vista
<script type="text/javascript">
    $(document).ready(function(){
        $("#bloquear").click(function(e){
            $.post("{{proyectodam/app/Lib/ServerSocket.php}}", {op: 1});
        });
    });
</script>ServerSocket.php
<?php 
namespace proyectodam\Lib;
try{
    set_time_limit(0);
    $address = '127.0.0.1';
    $port = 5555;
    // Create a TCP Stream socket
    $sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); // 0 for  SQL_TCP
    // Bind the socket to an address/port
    socket_bind($sock, $address, $port) or die('Could not bind to address');  //0 for localhost
    // Start listening for connections
    socket_listen($sock);
    //loop and listen
    while(true){
      /* Accept incoming  requests and handle them as child processes */
      $client = socket_accept($sock);
      //$_SESSION[socket_getpeername($client, AF_INET, 5555)] = socket_getpeername($client, AF_INET, 5555);
      // Read the input  from the client – 1024000 bytes
      //$input = socket_read($client, 1024000);
      // from here you need to do your database stuff
      // and handle the response 
       // Display output  back to client
      if(isset($_POST["op"])){
          $message = 1;
          socket_write($client, $message, strlen($message));
      }
      socket_close($client);
    }
    // Close the master sockets
    socket_close($sock);
}catch(Exception $e){
    echo 'Excepción capturada: ',  $e->getMessage(), "\n";
}
Cliente en java
public class ClienteSocket{
    public static void main(String args[]){
        try {
            Socket client = new Socket("127.0.0.1", 5555);
            BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
            OutputStreamWriter wr = new OutputStreamWriter(client.getOutputStream());
            String op;
            while((op = in.readLine()) != null){
                System.out.println(op);
            }
        }catch (IOException e){
            System.out.println("error");
            e.printStackTrace();
        }
    }
}Pues no consigo interceptar desde el servidor la solicitud ajax que hago desde jquery al servidor para que luego este se lo envie al cliente(java).



