php-src/ext/sockets/tests/socket_send.phpt

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-11-18 00:08:08 +00:00
--TEST--
int socket_send ( resource $socket , string $buf , int $len , int $flags );
--CREDITS--
marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
--SKIPIF--
<?php
if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
2015-11-18 00:08:08 +00:00
if (!extension_loaded('sockets')) {
die('SKIP sockets extension not available.');
}
?>
--FILE--
<?php
$port = 80;
$host = "yahoo.com";
$stringSocket = "send_socket_to_connected_socket";
2018-02-05 00:16:50 +00:00
$stringSocketLength = strlen($stringSocket);
2015-11-18 00:08:08 +00:00
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$socketConn = socket_connect($socket, $host, $port);
2018-02-05 00:16:50 +00:00
if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_OOB)===$stringSocketLength){
2015-11-18 00:08:08 +00:00
print("okey\n");
}
if(!defined('MSG_EOR') || socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOR)===$stringSocketLength){
2015-11-18 00:08:08 +00:00
print("okey\n");
}
if(!defined('MSG_EOF') || socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOF)===$stringSocketLength){
2015-11-18 00:08:08 +00:00
print("okey\n");
}
2018-02-05 00:16:50 +00:00
if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_DONTROUTE)===$stringSocketLength){
2015-11-18 00:08:08 +00:00
print("okey\n");
}
?>
<?php
socket_close($socket);
unset($port);
unset($host);
unset($stringSocket);
2018-02-05 00:16:50 +00:00
unset($stringSocketLength);
2015-11-18 00:08:08 +00:00
unset($socket);
unset($socketConn);
?>
--EXPECT--
2015-11-18 00:08:08 +00:00
okey
okey
okey
okey