Re: PHP connection to external application

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

 



On Thu, Jun 12, 2008 at 9:30 PM, Stut <stuttle@xxxxxxxxx> wrote:
> On 12 Jun 2008, at 12:20, hce wrote:
>>
>> What is the best way for a PHP web application to connect to an
>> external application written by C in Linux OS?
>>
>> (1) Can PHP directly call external C functions, or similar solution?
>
> No, but you can wrap the C functions in a PHP extension.

Ok, that is not an option.

>> (2) Can PHP pass messages to message queue which external C program can
>> access?
>
> Depends on the implementation of the queue, but the answer is almost
> certainly yes.

I am not certain if the msg_send / msg_receive in PHP can talk to the
external C program msg_send  / msg_receive as PHP and external C
program are in different processes, different memory spaces. Unless
wrap the C functions in a PHP extension as your suggested in (1).


>> (3) Socket connection between the PHP and external C program.
>
> This would usually be my preferred choice unless there is a particular
> reason to avoid this in which case I would go down the PHP extension route.
>
> A lot will depend on what the C code is doing and how your PHP scripts will
> interact with it.

Let me first describe the requirement more:

The C program is a major business server which accesses the database,
exchanges information to other remote servers and it has many other
background tasks running concurrently for doing monitor, statistic
report, real time update data, etc.

The PHP web application connects to the C program to get data and
information and to display on user's web browser. I know socket works
between the PHP and external C server, but there are many concerns
depends on different implementations:

(a) A simple way is if for every PHP request, it opens socket, sends a
request and gets a response from the C server then closes the socket.
It should work, but I am not sure:
   (i) if the open / close socket per request will cause delays and
performance issues.
   (ii) What is the maximum number concurrent requests in a PHP web
application? Will the maximum socket number  / or port number (up to
2^16) be a bottleneck for large number of concurrent requests (hundred
and thousands)?

(b) If for all PHP requests share only one socket to connect to the
external C server, I am not sure if the PHP is able to do multiplex
responses for each request as the PHP is stateless.

Thank you.

Jim

-- 
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