fsockopen - how can I specify the local/source port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am experimenting with the fsockopen function to send custom UDP packets. 
What I would like to do is to be able to nominate the LOCAL port that my UDP 
packet originates from. What happens currently is that when I execute my 
code below I get a random port >1023 allocated. What I want to be able to do 
is to fix the port to one that I specify.

The code below works and I can see my packet being sent out to destination 
port 7077.  The 192.168.2.10 server is also watching for the source port of 
incoming traffic and will only respond if the source port is also 7077.

<?php
$fp = fsockopen("udp://192.168.2.10", 7077, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
    fwrite($fp, "Test\n");
    echo fread($fp, 26);
    fclose($fp);
}
?>

Any ideas how I can achieve this?

Thanks,
Matt 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux