Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple php server and client 1

Status
Not open for further replies.

chals1

Technical User
Sep 3, 2003
73
ES
I'm a very newbie on php and don't figure out how sockets work. Can you show any simple code? For example a client which sends a string to a server at known ip and this one sends back a message
 
I get an error when running a script with sockets.It says something like..

Fatal error: Call to undefined function: socket_create() in C:\Archivos de programa\Abyss Web Server\htdocs\sock.php on line 2

Do I need to install some kind of module for it to work???
 
Code:
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 
socket_bind($socket,'localhost',1337); 
socket_listen($socket);
while($connection = socket_accept($socket)) 
{ 
socket_write($connection,'You\'ve successfully connected to my
computer!\r\n'); 
           } 
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top