我正在尝试使用PHP打开套接字并将其连接到Java应用程序。我每次尝试都会超时。我使用过http://canyouseeme.org,所以我确信端口是打开的,Java应用程序正在运行。我设法打开了一个本地PHP服务器,这是我可以让PHP连接的最接近的东西。
PHP:
$port = 8040;
$address = "*removed-ip*";
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$connection = socket_connect($socket, $address, $port);
爪哇:
ServerSocket socket;
Socket connection;
socket = new ServerSocket(8040);
while(done == false) {
connection = socket.accept();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
}