How does PHP Socket works in term of structure - php

I just curious about how php socket work in term of its structure? I had tried to create a server socket with port 80 which is occupied by my Web server and it run perfectly without error. Is it keeping its own port list instead of using the system port? I hope can get more explanation and clarification.
Thank you for your explanation.

Related

Asterisk with FastAgi + Remote PC (Windows) PHP file

I am a newbie to asterisk and found it really interesting! I've been able to create a dial plan that works perfect, but, I am stuck on working with FastAgi. I want asterisk to run my PHP script that is placed on my windows server remote machine. I have called fast AGI as show below:
exten => s,n,AGI(agi://192.168.0.101/tts.php?number=123456789&pin=123)
But asterisk CLI always shows Connection refused or Connection refused for the url 192.168.0.101:4573/tts.php?number=123456789&pin=123
I wonder why is it appending the port by its own.
Need help to go through this Connection refusing thing, I have tried turning off the fire wall but still failure.
P.S: My PHP script is a simple one like the normal PHP script, nothing special.
Thank You in advanced
I have solved the question by my self. The only problem was that default port "4573" as my remote PC was not configured to listen this port. Any how, I solved it by simply adding a port to my IP like this "IP:80" and the connection was complete with response of 0.
Any how the script never fired after this so I use CURL function to get my php script running.
Thank You

Write a wrapper for ssl encryption to my simple written php socket server

I have googled around it and did not find much around it. There was one question on stack overflow regarding simple socket written in C to SSL socket, but i want that in PHP.
I am using a HTTP server written in PHP, whose details can be found in SocketDaemon.php in this link. The problem is that it is a simple http server with simple read writes which i want to wrap and make an SSL connection to this server, and make it listen to port 443.
Can i have some pointers on how to go about it.
stunnel totally worked in this case. It listened on 443 port and connected to 80 port internally, just what i wanted.

VPN Connection through PHP or some other server-side scripting?

Ok, let me first start off by saying that I've only ever dealt with VPN access through windows by setting up a connection through the control panel. It's pretty simple since everything is pretty much a point-and-click setup.
I'm now working on a project where I need to access a computer cloud on a private network (there is no public IP directly to the cloud so it can only be accessed when I'm on the network). My project involves a website that needs to access that cloud "somehow". Because of my lack of experience/knowledge with VPN's through the command line and how to programmatically connect to a VPN, I've hit a mild obstacle that I'm hoping someone here can help me with.
What kind of server side scripting would I do to get a VPN connection up and running? The website is being hosted on a linux machine. Is their a "default" VPN utility under linux that I can call through PHP to establish a connection? If not, I would really appreciate any and all suggestions on how to circumvent this little problem of mine. FYI the VPN uses PPTP.
Looks like there is a little bit to getting it set up from a shell rather than the GUI, but here are some references that will hopefully help you out.
If you set up the connection and connect it, when your PHP script attempts to communicate with an IP address on the remote side of the connection, it will go through the PPTP connection. Having the connection always open is probably better than having to your PHP script connect every time it needs to do something.
http://ubuntuforums.org/showthread.php?t=1443735 - An easy PPTP client setup
http://pptpclient.sourceforge.net/ - Client you can install and configure
http://www.cyberciti.biz/tips/howto-configure-ubuntu-fedora-linux-pptp-client.html - Walk through of setting up PPTP using the linux PPTP network manager
Hopefully those will help you out a bit. The first one looks like it may be worth trying first.

How could I read from PHP in another host

I have a proxy in our office which close all the trafic from certain ports. It's a big office so the Security manager won't open any ports. We need some data through the port 9001 which isn't opened.
To bypass this, I put a php script in my server which outputs an XML which needs to be read in my office network. So, I tested at home with a cUrl and worked flawlessly but it seems that now it's grabing nothing.
Tested with var_dump it shows: boolean false with the curl exec
What other methods could I use?
You could set up a VPN on an allowed port and connect through that. That would probably simplify a lot of other stuff as well. OpenVPN is pretty light and straight-forward to set up.
install a proxy on an external host which is listening on port 80 but fetches from port 9001

Read ssl data from PHP socket_listen()

Lets say a listening socket is created in PHP, and it accepts a secure connection.
How do I know that it's encrypted and how do I decode it?
From the way your question is worded, you are a very long way from being to implement any sort of solution to the question as you've asked it. Implementing your own SSL server using PHP and off the shelf components will be virtually impossible even for a total PHP guru. I don't imagine that anyone who really understood the problem would try to solve it in this way - a far more pragmatic approach would be to set up the server to listen on two different ports (or use 2 seperate servers) use an SSL proxy (e.g. stunnel) which only accepts connections from localhost for the SSL traffic, and write your server(s) to talk non-SSL. You know its secure if the connection arrives from localhost and on the port that listens for the stunnel connection (or someone is running their own client/proxy on your server).
HTH
C.

Categories