xref: /PHP-5.6/ext/sockets/tests/socket_send.phpt (revision f0b02f23)
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 (!extension_loaded('sockets')) {
8  die('SKIP sockets extension not available.');
9}
10if(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
21$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
22$socketConn = socket_connect($socket, $host, $port);
23
24if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_OOB)===$stringSocketLenght){
25  print("okey\n");
26}
27
28if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOR)===$stringSocketLenght){
29  print("okey\n");
30}
31
32if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOF)===$stringSocketLenght){
33  print("okey\n");
34}
35
36if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){
37  print("okey\n");
38}
39?>
40<?php
41socket_close($socket);
42unset($port);
43unset($host);
44unset($stringSocket);
45unset($stringSocketLenght);
46unset($socket);
47unset($socketConn);
48?>
49--EXPECTF--
50okey
51okey
52okey
53okey
54