Doc #78657 [Opn]: 'broken pipe' unless socket connected first
| From: | cmb@php.net | Date: | Wed, 09 Oct 2019 15:52:31 +0000 |
| Subject: | Doc #78657 [Opn]: 'broken pipe' unless socket connected first | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16997@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78657&edit=1
ID: 78657
Updated by: cmb@php.net
Reported by: a dot a dot paul at gmail dot com
Summary: 'broken pipe' unless socket connected first
Status: Open
Type: Documentation Problem
Package: *General Issues
Operating System: Android
PHP Version: 7.3.10
-Assigned To:
+Assigned To: pollita
Block user comment: N
Private report: N
New Comment:
It seems to me the docs are correct. Sara?
Previous Comments:
------------------------------------------------------------------------
[2019-10-09 13:47:56] a dot a dot paul at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.socket-sendto
---
Documentation states: "Sends a message to a socket, whether it is connected or not"
In practice PHP returns a 'broken pipe' error if the socket is not connected.
See description at stack overflow : https://stackoverflow.com/questions/41624814/php-socket-sendto-cannot-connect-to-any-host
Test script:
---------------
<?php
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "Ping !";
$len = strlen($msg);
socket_connect($sock, '127.0.0.1', 1223); // this line missing from documentation
socket_sendto($sock, $msg, $len, 0, '127.0.0.1', 1223);
socket_close($sock);
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78657&edit=1