php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78657 'broken pipe' unless socket connected first
Submitted: 2019-10-09 13:47 UTC Modified: 2019-10-13 18:38 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: a dot a dot paul at gmail dot com Assigned: pollita (profile)
Status: Assigned Package: Sockets related
PHP Version: 7.3.10 OS: Android
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: a dot a dot paul at gmail dot com
New email:
PHP Version: OS:

 

 [2019-10-09 13:47 UTC] 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);
?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-09 15:52 UTC] cmb@php.net
-Assigned To: +Assigned To: pollita
 [2019-10-09 15:52 UTC] cmb@php.net
It seems to me the docs are correct.  Sara?
 [2019-10-13 18:38 UTC] cmb@php.net
-Package: *General Issues +Package: Sockets related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Nov 16 21:01:32 2019 UTC