in reply to bind a client connection

you can use bind() on outgoing connections, e.g.,

bind(SOCKET, pack_sockaddr_in(0, inet_aton($local_ip)))

It's exactly the same as when you're setting up a server except that you're calling connect rather than listen

(... and the point of using pack_sockaddr_in is so that you don't have to create extra variables you don't need. Unlike with sockaddr_in which looks at its context to see whether it should be packing or unpacking, pack_sockaddr_in always packs... and you could do that with the connect() call as well to get rid of $iaddr and $paddr...)

Replies are listed 'Best First'.
Re^2: bind a client connection
by Anonymous Monk on Feb 11, 2012 at 22:29 UTC
      Without re-writing the code to use more [up] to date modules
        doesn't require rewriting code , simply swap 5 lines for one IO->new call