PHP Apache fsockopen to different port

1.5k views Asked by At

I currently have a development environment, using HTTPS ports. Each site is setup with a different port number so I can connect to https://192.168.0.100:2001.

I'm trying to use PHP to do an async call, but cannot figure out how to do so using PHP. I've got a standard Ubuntu LAMP setup, and have OpenSSL installed.

Given the url https://192.168.0.100:2002, how would I make the fsocketopen call?

This is taken from the PHP fsockopen page.

$fp = fsockopen("ssl://www.example.com", 443, $errno, $errstr, 30);
3

There are 3 answers

2
MidnightLightning On

That "443" in the sample from the PHP page is the port number for that function call. Normally HTTPS calls go over 443, but it looks like you're overriding that. Change the second parameter to 2001, 2002, etc. and it will connect to your various servers.

0
KomarSerjio On
<?php $fp = fsockopen("192.168.0.100", 2002, $errno, $errstr, 30); ?>
0
david.wosnitza On

dunnow 'bout fsockopen

i'd rather use file_get_contents() with (optionally) stream_context_create($opts)

depends on the data you recieve.