|
...
|
...
|
@@ -12,7 +12,6 @@ namespace App\Helper; |
|
|
|
class Socket
|
|
|
|
{
|
|
|
|
public function socket($data){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(1111, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
// Socket 服务器的 IP 和端口
|
|
|
|
$socketServerIp = '127.0.0.1';
|
|
|
|
$socketServerPort = 9555; // 替换为实际端口
|
|
...
|
...
|
@@ -32,8 +31,10 @@ class Socket |
|
|
|
socket_write($socket, 'ceshixiaoxi', strlen('ceshixiaoxi'));
|
|
|
|
// 从服务器接收数据
|
|
|
|
$response = socket_read($socket, 1024);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($response, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
// 关闭 Socket 连接
|
|
|
|
socket_close($socket);
|
|
|
|
|
|
|
|
return response()->json(['response' => $response]);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|