socket_send.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. --EXTENSIONS--
  6. sockets
  7. --SKIPIF--
  8. <?php
  9. if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
  10. ?>
  11. --FILE--
  12. <?php
  13. $port = 80;
  14. $host = "yahoo.com";
  15. $stringSocket = "send_socket_to_connected_socket";
  16. $stringSocketLength = strlen($stringSocket);
  17. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  18. $socketConn = socket_connect($socket, $host, $port);
  19. if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_OOB)===$stringSocketLength){
  20. print("okey\n");
  21. }
  22. if(!defined('MSG_EOR') || socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOR)===$stringSocketLength){
  23. print("okey\n");
  24. }
  25. if(!defined('MSG_EOF') || socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOF)===$stringSocketLength){
  26. print("okey\n");
  27. }
  28. if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_DONTROUTE)===$stringSocketLength){
  29. print("okey\n");
  30. }
  31. ?>
  32. <?php
  33. socket_close($socket);
  34. unset($port);
  35. unset($host);
  36. unset($stringSocket);
  37. unset($stringSocketLength);
  38. unset($socket);
  39. unset($socketConn);
  40. ?>
  41. --EXPECT--
  42. okey
  43. okey
  44. okey
  45. okey