xref: /PHP-7.3/ext/sockets/tests/socket_send.phpt (revision ded3d984)
1--TEST--
2int socket_send ( resource $socket , string $buf , int $len , int $flags );
3--CREDITS--
4marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
5--SKIPIF--
6<?php
7if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
8if (!extension_loaded('sockets')) {
9  die('SKIP sockets extension not available.');
10}
11if(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
22$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
23$socketConn = socket_connect($socket, $host, $port);
24
25if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_OOB)===$stringSocketLength){
26  print("okey\n");
27}
28
29if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOR)===$stringSocketLength){
30  print("okey\n");
31}
32
33if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_EOF)===$stringSocketLength){
34  print("okey\n");
35}
36
37if(socket_send($socket, $stringSocket, $stringSocketLength, MSG_DONTROUTE)===$stringSocketLength){
38  print("okey\n");
39}
40?>
41<?php
42socket_close($socket);
43unset($port);
44unset($host);
45unset($stringSocket);
46unset($stringSocketLength);
47unset($socket);
48unset($socketConn);
49?>
50--EXPECT--
51okey
52okey
53okey
54okey
55