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:3
Avg. Score:3.0 ± 1.6
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 21:01:28 2024 UTC