For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > January 2006 > #36109 [Opn]: socket_sendto throws error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #36109 [Opn]: socket_sendto throws error
tony2001@php.net

2006-01-23, 6:57 pm

ID: 36109
Updated by: tony2001@php.net
Reported By: mike at normi dot net
Status: Open
-Bug Type: Sockets related
+Bug Type: Documentation problem
Operating System: *
PHP Version: 5.1.2
New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2006-01-20 22:03:10] sniper@php.net

The example doesn't work for me either. (on linux)
I get "broken pipe" error..

------------------------------------------------------------------------

[2006-01-20 21:02:55] 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\clanho
st.nl\onlydutch\HTML\test2.php
on line 8


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=36109&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com