Thread: TSockets
View Single Post
  #3  
Old 04-09-2012, 02:24 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
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_INETSOCK_STREAMSOL_TCP);
  
socket_connect ($sock$ip$port);
  
$dat 'Test';
  
$len strlen($msg);
  
socket_send($sock$dat$lenMSG_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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 04-09-2012 at 04:31 PM..
Reply With Quote