From:             aeolianmeson at blitzeclipse dot com
Operating system: Fedora 4
PHP version:      5.1.4
PHP Bug Type:     Sockets related
Bug description:  Always tries to connect to client on same outgoing port

Description:
------------
I am connecting to myself and then closing, to sniff out available ports
on my system that I can use-- I'm sure you're acquainted with this
method.

It should always produce a different port (nPort), since no connection is
erected (because it's UDP), but it always returns that it is on the SAME
port.


Dustin Oprea

Reproduce code:
---------------
$n = 10;
while($n--)
{
        $strIP = $nPort = -1;

        $Socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
        socket_connect($Socket, '172.0.0.1', 8400);
        socket_getsockname($Socket, $strAddr, $nPort);
        socket_close($Socket);

        print("> Available port: $strAddr:$nPort\n");
}

Expected result:
----------------
It produces ten lines of output, that should each contain one unique,
available port number. 

Actual result:
--------------
Each line indicates the same port, even if a socket has been opened for
listening on it.


The problem I am having, therefore, is that I sniff the next available
port from this code, and set up a listener on it. I then do the same thing
again in order to open another listener on a different port, but it always
returns to me the same port number, and I can not not bind it, obviously.

Is this intended?

-- 
Edit bug report at http://bugs.php.net/?id=38043&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38043&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38043&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38043&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38043&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38043&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38043&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38043&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38043&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38043&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38043&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38043&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38043&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38043&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38043&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38043&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38043&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38043&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38043&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38043&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38043&r=mysqlcfg

Reply via email to