Can PHP and pureBasic communicate through port 80?

Everything else that doesn't fall into one of the other PB categories.
Alberto
User
User
Posts: 25
Joined: Mon May 19, 2003 4:59 pm

Can PHP and pureBasic communicate through port 80?

Post by Alberto »

I explain better my question.

My company wants to make available through internet to his distributors the disponibility, the prices and other few things of our database.

The normal way is to make a web server but I don't like this way because a Windows web server is very dangerous to administrate for security (it needs continuous updates and a really expert for security) and is also expensive.

I ask you if it's possible to do a tunnel through port 80 that pass our LAN firewall. The purpose of this tunnel is to communicate with our website located on a internet server outside from our LAN.
When a distributor wants to know the disponibility or to reserve a product he communicates with our web site located in Internet. Our website contains PHP functions that communicates through port 80 to a purebasic program running on the server of our LAN.

It's like the idea behind the SOAP but made in pureBasic.

I know how to connect to our database using pureBasic.
I know how to scan continuously a computer port for a comunication in PureBasic.

I don't know how to realize a communication from a PHP program and a Purebasic that acts like a server on a machine located in a LAN where there is a firewall and the only way to go in or out is the port 80 (the security is guaranteeed)

Any suggestion?

Thank you in advance.

Alberto
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Alberto,

Have you looked at the Atomic Web server example? You'll find it in the "Sources - Advanced" folder.

You can split the code into two parts: the port listener which listens for requests and the protocol handler.

The protocol handler just converts the request into a path on the web server and then returns the file it refers to.

You will want to replace the protocol part with one that fits your requests. Something that identifies whatever you'll be publishing rather than files on a server.

PHP would then access Purebasic on port 80 the same way it would any other server over the web.

Something like:
$fp = fsockopen("url.or.ip", 80, $errno, $errstr, 30);

Docs are here:
http://www.php.net/manual/en/function.fsockopen.php
Alberto
User
User
Posts: 25
Joined: Mon May 19, 2003 4:59 pm

Post by Alberto »

Thank you for your answer GedB.

It's always a beautiful surprise for me to find people like you that help
their pureBasicbrother. :D

Your solution is very good.

I also think that the fsockopen is the right function to use in PHP but I can't understand what put in the "url.or.ip" parameter.

I'm connected with an ADSL connection that has a static IP that is 63.123.041.111 (for example). The router/firewall is than connected to a hub and a LAN. In the LAN the computer where run my AtomicWebServer (or a modified version of it) is 192.168.11.1 (for example).

What I've to write in the "url.or.ip" parameter of the fsockopen function?

Thank you for your answer.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

alberto, do a search on the forum, i've posted a winsock example if you want to do it directly yourself with winapi's
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply