Hi gpstrack,
I want to do something similar. I used a php script I found on the web to listen on a predifined port to anything coming in. But I can't get my php script running at my localhost.
The php script is:
<?php
// Server IP address
$address = "127.0.0.1";
// Port to listen
$port = 1000;
set_include_path("C:\Program Files\EasyPHP-5.3.2\php\ext");
$mysock = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not bind to address\n") ;
socket_bind($mysock, $address, $port) or die('Could not bind to address');
socket_listen($mysock, 5);
$client = socket_accept($mysock);
read 1024 bytes from client
$input = socket_read($client, 1024);
write received data to the file
writeToFile('abc.txt', $input);
socket_close($client);
socket_close($mysock);
?>
<?
/**
* write string to file
*/
function writeToFile($strFilename, $strText)
{
if($fp = @fopen($strFilename,"w "))
{
$contents = fwrite($fp, $strText);
fclose($fp);
return true;
}else{
return false;
}
}
?>
what is wrong with this script?
Thanks in advance, raven47


2Likes
LinkBack URL
About LinkBacks
Reply With Quote
without knowing what to do and how to do the following:


