Do not create a new socket when one is provided (#7358)

Check that the current socket in the object is false before trying to create a new socket
This commit is contained in:
frytimo
2025-04-25 13:38:43 -03:00
committed by GitHub
parent 370b2e1e27
commit c4e63c2562

View File

@@ -144,8 +144,11 @@ class event_socket {
$port = $port ?? $conf['switch.event_socket.port'] ?? $conf['event_socket.port'] ?? '8021';
$password = $password ?? $conf['switch.event_socket.password'] ?? $conf['event_socket.password'] ?? 'ClueCon';
//open the socket connection
$this->fp = @fsockopen($host, $port, $errno, $errdesc, 3);
//if a socket was provided in the constructor then don't create a new one
if ($this->fp === false) {
//open the socket connection
$this->fp = @fsockopen($host, $port, $errno, $errdesc, 3);
}
if (!$this->connected()) {
return false;