xref: /PHP-7.1/ext/sockets/tests/socket_send.phpt (revision 283b0cc8)
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$stringSocketLenght = 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, $stringSocketLenght, MSG_OOB)===$stringSocketLenght){
26  print("okey\n");
27}
28
29if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOR)===$stringSocketLenght){
30  print("okey\n");
31}
32
33if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOF)===$stringSocketLenght){
34  print("okey\n");
35}
36
37if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){
38  print("okey\n");
39}
40?>
41<?php
42socket_close($socket);
43unset($port);
44unset($host);
45unset($stringSocket);
46unset($stringSocketLenght);
47unset($socket);
48unset($socketConn);
49?>
50--EXPECTF--
51okey
52okey
53okey
54okey
55