socket_send.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 not for windows');
  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_EOR)===$stringSocketLenght){
  26. print("okey\n");
  27. }
  28. if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOF)===$stringSocketLenght){
  29. print("okey\n");
  30. }
  31. if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){
  32. print("okey\n");
  33. }
  34. ?>
  35. <?php
  36. socket_close($socket);
  37. unset($port);
  38. unset($host);
  39. unset($stringSocket);
  40. unset($stringSocketLenght);
  41. unset($socket);
  42. unset($socketConn);
  43. ?>
  44. --EXPECTF--
  45. okey
  46. okey
  47. okey
  48. okey