note 50286 rejected from function.socket-listen by nicobn
| From: | nicobn@php.net | Date: | Tue, 03 Jul 2007 19:57:05 +0000 |
| Subject: | note 50286 rejected from function.socket-listen by nicobn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128195@lists.php.net to get a copy of this message | ||
Note Submitter: john at bhdnet dot com
----
One suggestion for the above example for working with UDP.
The example uses the same socket to connect to a machine thus closing the listening socket and
forcing the re-creation of a new UDP socket and wasting alot of processor time.
Instead it would be better to follow the standard TCP/IP operation method whereby you have one
socket listening and create new sockets to form active connections.
So when the UDP socket is incoming create a new socket identical (bind to a different port number)
and then connect.
Of course, if you wanted bi-directional communication you should always use TCP/IP because it is
more reliable and has methods of packet arrangement and recovery.