socket_send_win32.phpt 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. int socket_send ( resource $socket , string $buf , int $len , int $flags );
  3. --CREDITS--
  4. marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
  5. --SKIPIF--
  6. <?php
  7. if (!extension_loaded('sockets')) {
  8. die('SKIP sockets extension not available.');
  9. }
  10. if(substr(PHP_OS, 0, 3) != 'WIN' ) {
  11. die('skip windows only test');
  12. }
  13. ?>
  14. --FILE--
  15. <?php
  16. $port = 80;
  17. $host = "yahoo.com";
  18. $stringSocket = "send_socket_to_connected_socket";
  19. $stringSocketLenght = strlen($stringSocket);
  20. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  21. $socketConn = socket_connect($socket, $host, $port);
  22. if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_OOB)===$stringSocketLenght){
  23. print("okey\n");
  24. }
  25. if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){
  26. print("okey\n");
  27. }
  28. ?>
  29. <?php
  30. socket_close($socket);
  31. unset($port);
  32. unset($host);
  33. unset($stringSocket);
  34. unset($stringSocketLenght);
  35. unset($socket);
  36. unset($socketConn);
  37. ?>
  38. --EXPECTF--
  39. okey
  40. okey