JAVA代码:
import java.io.*;
import java.net.*;
class Server {
public static void main(String args[]) {
try {
ServerSocket srvr = new ServerSocket(51);
Socket skt = srvr.accept();
System.out.print("Server has connected!\n");
PrintWriter out =
new PrintWriter(skt.getOutputStream(), true);
BufferedReader in =
new BufferedReader(new InputStreamReader(skt.getInputStream()));
if(in.readLine() == "xFF"){
out.print("OK");
}
in.close();
out.close();
skt.close();
srvr.close();
}
catch(Exception e) {
System.out.print("Whoops! It didn't work!\n");
}
}
}
PHP代码:
<?php
$con = fsockopen("127.0.0.1", 51, $errno, $errstr, 10);
fwrite($con, "xFF");
if(fread($con, 256) == "OK"){
// Its Works
}
?>
PHP 代码返回:致命错误:第 7 行 C:\xampp\htdocs\index.php 中的最大执行时间超过 60 秒