socket_send.phpt 1.3 KB

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