class Server (View source)

Properties

$setting
$connections
$host
$port
$type
$mode
$ports
$master_pid
$manager_pid
$worker_id
$taskworker
$worker_pid
$stats_timer
Server Since: 4.8.0
$admin_server

Methods

__construct($host, $port = null, $mode = null, $sock_type = null)

No description

__destruct()

No description

mixed
listen(mixed $host, mixed $port, mixed $sock_type)

No description

mixed
addlistener(mixed $host, mixed $port, mixed $sock_type)

No description

mixed
on(mixed $event_name, callable $callback)

No description

mixed
getCallback(mixed $event_name)

No description

mixed
set(array $settings)

No description

mixed
start()

No description

mixed
send(mixed $fd, mixed $send_data, mixed|null $server_socket = null)

No description

mixed
sendto(mixed $ip, mixed $port, mixed $send_data, mixed|null $server_socket = null)

No description

mixed
sendwait(mixed $conn_fd, mixed $send_data)

No description

mixed
exists(mixed $fd)

No description

mixed
exist(mixed $fd)

No description

mixed
protect(mixed $fd, mixed|null $is_protected = null)

No description

mixed
sendfile(mixed $conn_fd, mixed $filename, mixed|null $offset = null, mixed|null $length = null)

No description

mixed
close(mixed $fd, mixed|null $reset = null)

No description

mixed
confirm(mixed $fd)

No description

mixed
pause(mixed $fd)

No description

mixed
resume(mixed $fd)

No description

mixed
task(mixed $data, mixed|null $worker_id = null, callable|null $finish_callback = null)

No description

mixed
taskwait(mixed $data, mixed|null $timeout = null, mixed|null $worker_id = null)

No description

mixed
taskWaitMulti(array $tasks, mixed|null $timeout = null)

No description

mixed
taskCo(array $tasks, mixed|null $timeout = null)

No description

mixed
finish(mixed $data)

No description

mixed
reload()

No description

mixed
shutdown()

No description

mixed
stop(mixed|null $worker_id = null)

No description

mixed
getLastError()

No description

mixed
heartbeat(mixed $reactor_id)

No description

mixed
getClientInfo(mixed $fd, mixed|null $reactor_id = null)

No description

mixed
getClientList(mixed $start_fd, mixed|null $find_count = null)

No description

int|false
getWorkerId()

Get the ID of current worker (either an event worker or a task worker).

int|false
getWorkerPid(int $worker_id = -1)

Get the process ID of a given worker process (specified by a worker ID).

mixed
getWorkerStatus(mixed|null $worker_id = null)

No description

mixed|false
command(string $name, int $process_id, int $process_type, mixed $data, bool $json_decode = true)

Run a customized command in a specified process of Swoole.

bool
addCommand(string $name, int $accepted_process_types, callable $callback)

Add a customized command.

mixed
getManagerPid()

No description

mixed
getMasterPid()

No description

mixed
connection_info(mixed $fd, mixed|null $reactor_id = null)

No description

mixed
connection_list(mixed $start_fd, mixed|null $find_count = null)

No description

mixed
sendMessage(mixed $message, mixed $dst_worker_id)

No description

int|false
addProcess(Process $process)

No description

mixed
stats()

No description

mixed
getSocket(mixed|null $port = null)

No description

mixed
bind(mixed $fd, mixed $uid)

No description

int
after(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::after().

int
tick(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::tick().

bool
clearTimer(int $timer_id)

Alias of method \Swoole\Timer::clear().

true
defer(callable $callback)

Alias of method \Swoole\Event::defer().

Details

__construct($host, $port = null, $mode = null, $sock_type = null)

No description

Parameters

$host
$port
$mode
$sock_type

__destruct()

No description

mixed listen(mixed $host, mixed $port, mixed $sock_type)

No description

Parameters

mixed $host
mixed $port
mixed $sock_type

Return Value

mixed

mixed addlistener(mixed $host, mixed $port, mixed $sock_type)

No description

Parameters

mixed $host
mixed $port
mixed $sock_type

Return Value

mixed

mixed on(mixed $event_name, callable $callback)

No description

Parameters

mixed $event_name
callable $callback

Return Value

mixed

mixed getCallback(mixed $event_name)

No description

Parameters

mixed $event_name

Return Value

mixed

mixed set(array $settings)

No description

Parameters

array $settings

Return Value

mixed

mixed start()

No description

Return Value

mixed

mixed send(mixed $fd, mixed $send_data, mixed|null $server_socket = null)

No description

Parameters

mixed $fd
mixed $send_data
mixed|null $server_socket

Return Value

mixed

mixed sendto(mixed $ip, mixed $port, mixed $send_data, mixed|null $server_socket = null)

No description

Parameters

mixed $ip
mixed $port
mixed $send_data
mixed|null $server_socket

Return Value

mixed

mixed sendwait(mixed $conn_fd, mixed $send_data)

No description

Parameters

mixed $conn_fd
mixed $send_data

Return Value

mixed

mixed exists(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed exist(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed protect(mixed $fd, mixed|null $is_protected = null)

No description

Parameters

mixed $fd
mixed|null $is_protected

Return Value

mixed

mixed sendfile(mixed $conn_fd, mixed $filename, mixed|null $offset = null, mixed|null $length = null)

No description

Parameters

mixed $conn_fd
mixed $filename
mixed|null $offset
mixed|null $length

Return Value

mixed

mixed close(mixed $fd, mixed|null $reset = null)

No description

Parameters

mixed $fd
mixed|null $reset

Return Value

mixed

mixed confirm(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed pause(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed resume(mixed $fd)

No description

Parameters

mixed $fd

Return Value

mixed

mixed task(mixed $data, mixed|null $worker_id = null, callable|null $finish_callback = null)

No description

Parameters

mixed $data
mixed|null $worker_id
callable|null $finish_callback

Return Value

mixed

mixed taskwait(mixed $data, mixed|null $timeout = null, mixed|null $worker_id = null)

No description

Parameters

mixed $data
mixed|null $timeout
mixed|null $worker_id

Return Value

mixed

mixed taskWaitMulti(array $tasks, mixed|null $timeout = null)

No description

Parameters

array $tasks
mixed|null $timeout

Return Value

mixed

mixed taskCo(array $tasks, mixed|null $timeout = null)

No description

Parameters

array $tasks
mixed|null $timeout

Return Value

mixed

mixed finish(mixed $data)

No description

Parameters

mixed $data

Return Value

mixed

mixed reload()

No description

Return Value

mixed

mixed shutdown()

No description

Return Value

mixed

mixed stop(mixed|null $worker_id = null)

No description

Parameters

mixed|null $worker_id

Return Value

mixed

mixed getLastError()

No description

Return Value

mixed

mixed heartbeat(mixed $reactor_id)

No description

Parameters

mixed $reactor_id

Return Value

mixed

mixed getClientInfo(mixed $fd, mixed|null $reactor_id = null)

No description

Parameters

mixed $fd
mixed|null $reactor_id

Return Value

mixed

mixed getClientList(mixed $start_fd, mixed|null $find_count = null)

No description

Parameters

mixed $start_fd
mixed|null $find_count

Return Value

mixed

int|false getWorkerId()

Get the ID of current worker (either an event worker or a task worker).

Return Value

int|false

Returns the ID of current worker. Returns false if not called within a worker process (either an event worker process or a task worker process).

int|false getWorkerPid(int $worker_id = -1)

Get the process ID of a given worker process (specified by a worker ID).

Parameters

int $worker_id

Return Value

int|false

Returns the process ID of a given worker process (specified by a worker ID). If the worker ID is a negative integer or not passed in, returns the process ID of current worker process. Returns false if something wrong happens (e.g., the worker process doesn't exist, or an invalid worker ID specified.).

mixed getWorkerStatus(mixed|null $worker_id = null)

No description

Parameters

mixed|null $worker_id

Return Value

mixed

mixed|false command(string $name, int $process_id, int $process_type, mixed $data, bool $json_decode = true)

Since: 4.8.0

Run a customized command in a specified process of Swoole.

Parameters

string $name
int $process_id
int $process_type
mixed $data
bool $json_decode

Return Value

mixed|false

See also

Server::addCommand

bool addCommand(string $name, int $accepted_process_types, callable $callback)

Since: 4.8.0

Add a customized command.

Commands can be added to the master process, the manager process, or worker processes. Commands can only be added before the server is started.

Parameters

string $name
int $accepted_process_types

One or multiple types of processes. e.g., "SWOOLE_SERVER_COMMAND_EVENT_WORKER | SWOOLE_SERVER_COMMAND_TASK_WORKER".

callable $callback

The callback function should return a (serialized) string back.

Return Value

bool

TRUE if succeeds, otherwise FALSE.

See also

Server::command
SWOOLE_SERVER_COMMAND_MASTER
SWOOLE_SERVER_COMMAND_MANAGER
SWOOLE_SERVER_COMMAND_EVENT_WORKER
SWOOLE_SERVER_COMMAND_TASK_WORKER

mixed getManagerPid()

No description

Return Value

mixed

mixed getMasterPid()

No description

Return Value

mixed

mixed connection_info(mixed $fd, mixed|null $reactor_id = null)

No description

Parameters

mixed $fd
mixed|null $reactor_id

Return Value

mixed

mixed connection_list(mixed $start_fd, mixed|null $find_count = null)

No description

Parameters

mixed $start_fd
mixed|null $find_count

Return Value

mixed

mixed sendMessage(mixed $message, mixed $dst_worker_id)

No description

Parameters

mixed $message
mixed $dst_worker_id

Return Value

mixed

int|false addProcess(Process $process)

No description

Parameters

Process $process

Return Value

int|false

Return the ID of the process (\Swoole\Process::$id) back if succeeds; otherwise return FALSE.

See also

Process::$id

mixed stats()

No description

Return Value

mixed

mixed getSocket(mixed|null $port = null)

No description

Parameters

mixed|null $port

Return Value

mixed

mixed bind(mixed $fd, mixed $uid)

No description

Parameters

mixed $fd
mixed $uid

Return Value

mixed

int after(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::after().

Parameters

int $ms
callable $callback
...$params

Return Value

int

See also

Timer::after

int tick(int $ms, callable $callback, ...$params)

Alias of method \Swoole\Timer::tick().

Parameters

int $ms
callable $callback
...$params

Return Value

int

See also

Timer::tick

bool clearTimer(int $timer_id)

Alias of method \Swoole\Timer::clear().

Parameters

int $timer_id

Return Value

bool

See also

Timer::clear

true defer(callable $callback)

Alias of method \Swoole\Event::defer().

Parameters

callable $callback

Return Value

true

See also

Event::defer