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
|
2016-08-11 09:08:04 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2019-10-12 14:27:24 +00:00
|
|
|
if(!defined('MSG_EOR') || socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOR)===$stringSocketLength){
|
2015-11-18 00:08:08 +00:00
|
|
|
print("okey\n");
|
|
|
|
}
|
|
|
|
|
2019-10-12 14:27:24 +00:00
|
|
|
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);
|
|
|
|
?>
|
2018-02-19 08:59:41 +00:00
|
|
|
--EXPECT--
|
2015-11-18 00:08:08 +00:00
|
|
|
okey
|
|
|
|
okey
|
|
|
|
okey
|
|
|
|
okey
|