php – Best way for two apps on the same machine to communicate – Education Career Blog

I have an ASP.NET app running on a webserver. A third party is created another app in PHP which needs to send data to my app for processing.

Initially it was assumed that the PHP app would be deployed elsewhere so we agreed that the communication would occur over the internet via HTTP (over SSL). My app would simply use a generic handler (ashx) file to recieve the data and send confirmation back.

Now it seems that the PHP app might be deployed on the same machine as my app. I like the fact that using HTTP (as opposed to say direct database access), the PHP app needs to know nothing at all about how my app works. But using the public internet seems silly for communication between two apps on the same machine.

If the PHP app simply used a localhost address, would this ensure that all the data stays within the machine? Is there a better way to do this?

,

If the PHP simply used a localhost address, would this ensure that all the data stays within the machine?

Yes

Is there a better way to do this?

Makes sense to me. It’s a common architectual choice, and it makes it easier should the two apps be deployed on separate machines again in future.

,

The public Internet would never be used, even if the PHP app specified an address on an external interface. But if you want to be… overcautious… then just use 127.0.0.1.

,

Yes, if you configure your TCP-connection using localhost, there will be no traffic sent out to the web. We have lot of applications which communicates with services using the TCP interface. No traffic will ever leave the server.

If you are unable to change the address in the PHP app, you may consider adding a hosts entry and redirect it to the local machine instead.

,

If they are deployed to the same machine, they must have been set up with host headers so that the IIS sends the traffic to the correct website – it is true that they can be listening tio different ports and no host headers but being a public web site, this is not an option.

If host headers are setup – which I am pretty sure they are – you cannot use localhost.

Leave a Comment