ID:               49423
 Updated by:       sjo...@php.net
 Reported By:      david dot schueler at wapkamera dot de
 Status:           Feedback
 Bug Type:         Streams related
 Operating System: Gentoo Linux
 PHP Version:      5.2.10
 New Comment:

I can reproduce the behavior you describe, but only if there is no
process listening on port 5060. If I start "nc -l -u -p 5060", the
fwrites succeed. Do you have a program listening on port 5060? 


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

[2009-08-31 17:37:27] david dot schueler at wapkamera dot de

Again with latest php5.2:

~ # php test.php 
5.2.11RC2-dev
Outputting: REGISTER abc
Bytes written to socket: 0
Outputting: REGISTER
Bytes written to socket: 8
Outputting:  REGISTER
Bytes written to socket: 9
Outputting: REGISTER 
Bytes written to socket: 9

~ # tcpdump -i lo -s0 -A port 5060
tcpdump: verbose output suppressed, use -v or -vv for full protocol
decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
19:35:25.189697 IP localhost.5050 > localhost.5060: SIP, length: 8
E..$<....@.@..$...............#REGISTER
19:35:25.189911 IP localhost.5050 > localhost.5060: SIP, length: 9
E..%<....@.@.."...............$ REGISTER
19:35:25.189953 IP localhost.5050 > localhost.5060: SIP, length: 9
E..%<....@.@..!...............$REGISTER 
^C
3 packets captured
6 packets received by filter
0 packets dropped by kernel

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

[2009-08-31 16:54:28] david dot schueler at wapkamera dot de

Okay, here's a tcpdump output, which shows that the other REGISTER
strings are beeing sent:

km33 ~ # tcpdump -i lo -s0 -A port 5060
tcpdump: verbose output suppressed, use -v or -vv for full protocol
decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
18:42:22.598199 IP localhost.5050 > localhost.5060: SIP, length: 8
E..$|b...@.@..................#REGISTER
18:42:22.598231 IP localhost.5050 > localhost.5060: SIP, length: 9
E..%|c...@.@..................$ REGISTER
18:42:22.598242 IP localhost.5050 > localhost.5060: SIP, length: 9
E..%|d...@.@..................$REGISTER
^C
3 packets captured
6 packets received by filter
0 packets dropped by kernel

As you can see i'm sending from port 5050 to port 5060 (which is the
default SIP port). No other process is listening on port 5050. Only
asterisk is listening on port 5060, which i want to communicate with.

km33 ~ # netstat -anp | grep 5050
km33 ~ # netstat -anp | grep 5060
udp   0   0 0.0.0.0:5060   0.0.0.0:*   11132/asterisk

And i'm not blocking any ports on my system, because i'm not using any
firewall on my testsystem.

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

[2009-08-31 16:26:58] david dot schueler at wapkamera dot de

Yes i wanted to send as line feed. But it doesn't matter because even
sending "REGISTER \r\n" nor "REGISTER abc" is working on 5.2.10.

I made a little script for showing what is happening:

<?php
echo phpversion()."\n";

$opts = array('socket' => array("bindto" => "0:5050"));
$context = stream_context_create($opts);
$socket = stream_socket_client("udp://127.0.0.1:5060", $errno, $error,
30, STREAM_CLIENT_CONNECT, $context);

$s[] = "REGISTER abc";
$s[] = "REGISTER";
$s[] = " REGISTER";
$s[] = "REGISTER ";

foreach ($s as $out) {
        echo "Outputting: \"".$out."\"\n";
        $bytes = fwrite($socket,$out);
        echo "Bytes written to socket: ".$bytes."\n";
}       
?> 

And the output is:

Kienzle ~ # php fwrite.php 
5.2.10-pl0-gentoo
Outputting: "REGISTER abc"
Bytes written to socket: 0
Outputting: "REGISTER"
Bytes written to socket: 8
Outputting: " REGISTER"
Bytes written to socket: 9
Outputting: "REGISTER "
Bytes written to socket: 9

Kienzle ~ # uname -a
Linux Kienzle 2.6.27-gentoo-r8 #7 SMP Wed Apr 29 18:42:19 CEST 2009
x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ AuthenticAMD
GNU/Linux

On another system, running the same version of php:
km33 ~ # php test.php 
5.2.10-pl0-gentoo
Outputting: "REGISTER abc"
Bytes written to socket: 0
Outputting: "REGISTER"
Bytes written to socket: 8
Outputting: " REGISTER"
Bytes written to socket: 9
Outputting: "REGISTER "
Bytes written to socket: 9
km33 ~ # uname -a
Linux km33902 2.6.30-gentoo-r4 #2 SMP Tue Aug 4 17:44:21 CEST 2009
x86_64 AMD Phenom(tm) 9950 Quad-Core Processor AuthenticAMD GNU/Linux

And for example on a Debian System:
ns20 ~ # php test.php
5.2.0-8+etch15
Outputting: "REGISTER abc"
Bytes written to socket: 12
Outputting: "REGISTER"
Bytes written to socket: 0
Outputting: " REGISTER"
Bytes written to socket: 9
Outputting: "REGISTER "
Bytes written to socket: 0
e...@ns2014921:~$ uname -a
Linux ns2014921.ovh.net 2.6.24.2-xxxx-std-ipv4-32 #4 SMP Wed Feb 13
16:50:04 CET 2008 i686 GNU/Linux

Look, the problem occures at "REGISTER".

I use "tcpdump -i lo -s0 -A port 5060" to look for the packet being
sent. And if fwrite() returns 0 then there arent any bytes on the
interface. So the output seems to be true.

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

[2009-08-31 16:20:36] sjo...@php.net

Thank you for your report.

I could not reproduce your problem. You say it only fails to send
something if port 5060 is used. This leads me to think this issue is
specific to your computer. Maybe another program is running on port
5060, or a firewall has blocked this port. How do you determine whether
the packet is sent?

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

[2009-08-31 15:50:41] j...@php.net

And I guess you wanted to send the \r\n as line feed/break instead of
literal \r\n ? If so, you should put double quotes around the text..

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/49423

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

Reply via email to