I am trying to develop a code judge software in PHP for programming assignments. I would try o compile codes on a java server which would require socket programming.I have litle knowledge of socket programming in PHP. I googled and found a code doing some similar work.But i am still unable to get the jist of things..how does it actually work? The manuals are too technical to get a good understanding
here's a piece of the code,i have written comments as per my understanding:
$socket = fsockopen($compilerhost, $compilerport); // creates connection it returns the file pointer
if($socket) { // if it returns a file pointer
fwrite($socket, $_POST['filename']."\n"); //write the filename in the file pointer returned by socket and chagne line
$query = "SELECT time, input, output FROM problems WHERE sl='".$_POST['id']."'"; // select input,output,for the problem
$result = mysql_query($query);
$fields = mysql_fetch_array($result);
fwrite($socket, $fields['time']."\n"); // write the time in the file pointer returned
I do not understand how does fsockopen works?How is fwrite used here?
a note: while going through the code i nowhere found $compilerhost, $compilerport variables.
rectify my doubts.Thanks in advance and pardon for the bad english
$compilerhost
and$compilerport
to whatever is appropriate for your application. They're the name and port number of the server you want to connect to. – Horusdbinfo.php
, which is created byinstall.php
. – Horus