Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP Binding and Multithreading

Status
Not open for further replies.

Itshim

Programmer
Apr 6, 2004
277
US
Greetings,

I have two questions:
1. In PHP4 can I make script work so it binds to multiple IP's?

Basically in the script I am connecting to another server multiple times and retrieving some information. I would like to be able to tell PHP: for the first connection use this IP address, for the second connection use this IP address.

I believe this can be achieved using the socket extension; I just wanted to know if I am on the right track.

2. Is there a way to use multithreading in PHP4?

For this question I found the curl_multi_* functions, but they are only available in PHP5, I would like a solution in PHP4.

Any help on these two questions is greatly appreciated.

Thanks,
Itshim
 
A little more research has revealed the function 'pcntl_fork()' for multi-tasking in a script. I will need to do some more research, but am I on the right track?

Thanks,
Itshim
 
This code will work for IP binding in PHP5.
Code:
<?php

$conn = stream_context_create(array('socket'=>array('bindto' => "1.2.3.4:0")));
file_get_contents("[URL unfurl="true"]http://url",[/URL] NULL, $conn);

?>

Is there a way to achieve the same thing in PHP4?

Thanks,
Itshim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top