<?php
echo $_SERVER['REMOTE_PORT'];
// vars
$host = "192.168.1.2";
$port = "8080";
// dont time out
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET,SOCK_STREAM,0) or die ("Could no create socket");
// bind socket to port
$result = socket_bind($socket,$host,$port) or die ("Could not bind socket");
// start listening for connections
$result = socket_listen($socket,3) or ("Could not set up socket listener");
// accept incoming connections
// spawn another socket to handle communucation
$spawn = socket_accept($socket) or die("Could not accept incoming connection");
// read clients
$input = socket_read($spawn,1024);
// reverse client input and send back
$output = strrev($input);
socket_write($spawn,$output,strlen($output)) or die("could not write output");
socket_close($spawn);
socket_close($socket);
?>
so yeah... when i load the page it gives me this error: Warning: socket_bind() [function.socket-bind]: unable to bind address [0]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in C:\xampp\htdocs\sites\sockets\index.php on line 14
Could not bind socket
So yeah, i think its something todo with the port idk, please help :)
Edited by WingedPanther, 20 March 2009 - 01:33 PM.
add code tags (the PHP sheet)


Sign In
Create Account



Back to top









