php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36109 socket_sendto throws error
Submitted: 2006-01-20 21:02 UTC Modified: 2007-07-21 17:55 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mike at normi dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-01-20 21:02 UTC] mike at normi dot net
Description:
------------
The socket_sendto function doesn't seem to work. Even with the example code from the manual it throws an error. Any thoughts on this?

phpinfo() @ http://hlstatsx.onlydutch.nl/test.php
Result test script from manual @ http://hlstatsx.onlydutch.nl/test2.php

Reproduce code:
---------------
<?php
   $sh = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
   if (socket_bind($sh, '127.0.0.1', 4242)) {
       echo "Socket bound correctly";
   }
   $buf = 'Test Message';
   $len = strlen($buf);
   if (socket_sendto($sh, $buf, $len, 0x100, '192.168.0.2', 4242) !== false) {
       echo "Message sent correctly";
   }
   socket_close($sh);
?> 

Expected result:
----------------
Socket bound correctly
Message sent correctly

Actual result:
--------------
Socket bound correctly
Warning: socket_sendto() [function.socket-sendto]: unable to write to socket [0]: The attempted operation is not supported for the type of object referenced. in D:\Home\LocalUser\onlydutch\sites\clanhost.nl\onlydutch\HTML\test2.php on line 8

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-20 22:03 UTC] sniper@php.net
The example doesn't work for me either. (on linux)
I get "broken pipe" error..
 [2006-01-24 00:08 UTC] tony2001@php.net
If sendto is used on a connection-mode (SOCK_STREAM,SOCK_SEQPACKET) socket, the parameters to and tolen are ignored (and the error EISCONN may  be  returned  when       they  are  not NULL and 0), and the error ENOTCONN is returned when the socket was not actually connected.
(c) man sendto

Looks like we need a better example in the docs, that actually works.
Reclassified as docu problem.
 [2007-07-21 17:55 UTC] nicobn@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 16:00:03 2025 UTC