Ok well I stuffed up a bit there.
But now that that's working; sending data via PHP on the other hand isn't.
Here is my understanding of sockets.
For the server:
So first it creates a socket.
Next it binds the socket to a port.
Then it listens on the port.
Then if data is sent it accepts it.
For the client sending data:
First it creates a socket.
It then connects to the socket using the ip and port.
It then can send data through the socket.
Edit: I am getting this error in PHP
Host lookup failed [-10003]: Unknown server error
It also gives this error.
unable to connect to 50.23.136.181:58860 (Connection refused)
Here is my PHP code..
PHP Code:
$host = '50.23.136.181';
$port = '41106';
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect ($sock, $ip, $port);
$dat = 'Test';
$len = strlen($msg);
socket_send($sock, $dat, $len, MSG_OOB);
socket_close($sock);
I tried UDP and ICMP for creating the sockets, but they gave even more errors; I assume it's TCP?
I did however manage to get the GServer to echo data, but I had to connect to the ip and port using a socket testing program.
My main goal is to have an input text box and a send button.