Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. $data = [
  2. "command" => "login",
  3. "arguments" => [
  4. "userId" => my-id,
  5. "password" => my-password
  6. ]
  7. ];
  8.  
  9. $in = json_encode($data);
  10.  
  11. $service_port = 5124;
  12. $address = gethostbyname('xapia.x-station.eu');
  13.  
  14. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  15. if ($socket === false) {
  16. echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "n";
  17. }
  18.  
  19. $result = socket_connect($socket, $address, $service_port);
  20. if ($result === false) {
  21. echo "socket_connect() failed.nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "n";
  22. }
  23.  
  24.  
  25. socket_write($socket, $in, strlen($in));
  26.  
  27. while ($out = socket_read($socket, 2048)) {
  28. echo $out;
  29. }
  30.  
  31. socket_close($socket);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement