Swoole

目录

简介

类摘要

Swoole\Async

class Swoole\Async {

/* 方法 */

public static void dnsLookup ( string $hostname , callable $callback )

public static bool read ( string $filename , callable $callback [, integer $chunk_size [, integer $offset ]] )

public static void readFile ( string $filename , callable $callback )

public static void set ( array $settings )

public static void write ( string $filename , string $content [, integer $offset [, callable $callback ]] )

public static void writeFile ( string $filename , string $content [, callable $callback [, string $flags ]] )

}

Swoole\Async::dnsLookup

Async and non-blocking hostname to IP lookup.

说明

public static void Swoole\Async::dnsLookup ( string $hostname , callable $callback )

Warning

本函数还未编写文档,仅有参数列表。

参数

hostname
The host name.

callback
mixed callback ( string $hostname , string $ip )

hostname
The host name.

IP
The IP address.

Swoole\Async::read

Read file stream asynchronously.

说明

public static bool Swoole\Async::read ( string $filename , callable $callback [, integer $chunk_size [, integer $offset ]] )

参数

filename
The name of the file.

callback
mixed callback ( string $filename , string $content )

filename
The name of the file.

content
The content readed from the file stream.

chunk_size
The chunk length.

offset
The offset.

返回值

Whether the read is succeed.

Swoole\Async::readFile

Read a file asynchronously.

说明

public static void Swoole\Async::readFile ( string $filename , callable $callback )

参数

filename
The filename of the file being read.

callback
mixed callback ( string $filename , string $content )

filename
The name of the file.

content
The content readed from the file.

Swoole\Async::set

Update the async I/O options.

说明

public static void Swoole\Async::set ( array $settings )

参数

settings

Swoole\Async::write

Write data to a file stream asynchronously.

说明

public static void Swoole\Async::write ( string $filename , string $content [, integer $offset [, callable $callback ]] )

参数

filename
The filename being written.

content
The content writing to the file.

offset
The offset.

callback

Swoole\Async::writeFile

Description

说明

public static void Swoole\Async::writeFile ( string $filename , string $content [, callable $callback [, string $flags ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

filename
The filename being written.

content
The content writing to the file.

callback

flags

简介

类摘要

Swoole\Atomic

class Swoole\Atomic {

/* 方法 */

public integer add ([ integer $add_value ] )

public integer cmpset ( integer $cmp_value , integer $new_value )

public integer get ( void )

public integer set ( integer $value )

public integer sub ([ integer $sub_value ] )

}

Swoole\Atomic::add

Add a number to the value to the atomic object.

说明

public integer Swoole\Atomic::add ([ integer $add_value ] )

Add a number to the value to the atomic object.

参数

add_value
The value which will be added to the current value.

返回值

The new value of the atomic object.

Swoole\Atomic::cmpset

Compare and set the value of the atomic object.

说明

public integer Swoole\Atomic::cmpset ( integer $cmp_value , integer $new_value )

参数

cmp_value
The value to compare with the current value of the atomic object.

new_value
The value to set to the atomic object if the cmp_value is the same as the current value of the atomic object.

返回值

The new value of the atomic object.

Swoole\Atomic::__construct

Construct a swoole atomic object.

说明

public Swoole\Atomic::__construct ([ integer $value ] )

Swoole atomic object is a integer variable allows any processor to atomically test and modify. It is implemented based on CPU atomic instructions. The Swoole atomic variables have to defined before swoole_server->start.

Compare-and-swap (CAS) is an atomic instruction used in multithreading to achieve synchronization. It compares the content of a memory location with a given value and, only if they are the same, modifies the content of that memory location to a new given value.

参数

value
The value of the atomic object.

Swoole\Atomic::get

Get the current value of the atomic object.

说明

public integer Swoole\Atomic::get ( void )

Get the current value of the atomic object.

参数

此函数没有参数。

返回值

The current value of the atomic object.

Swoole\Atomic::set

Set a new value to the atomic object.

说明

public integer Swoole\Atomic::set ( integer $value )

Set a new value to the atomic object.

Warning

本函数还未编写文档,仅有参数列表。

参数

value
The value to set to the atomic object.

返回值

The current value of the atomic object.

Swoole\Atomic::sub

Subtract a number to the value of the atomic object.

说明

public integer Swoole\Atomic::sub ([ integer $sub_value ] )

Subtract a number to the value of the atomic object.

参数

sub_value
The value which will be subtracted to the current value.

返回值

The current value of the atomic object.

简介

类摘要

Swoole\Buffer

class Swoole\Buffer {

/* 方法 */

public integer append ( string $data )

public void clear ( void )

public void __destruct ( void )

public integer expand ( integer $size )

public string read ( integer $offset , integer $length )

public void recycle ( void )

public string substr ( integer $offset [, integer $length [, bool $remove ]] )

public string __toString ( void )

public void write ( integer $offset , string $data )

}

Swoole\Buffer::append

Append the string or binary data at the end of the memory buffer and return the new size of memory allocated.

说明

public integer Swoole\Buffer::append ( string $data )

参数

data
The string or binary data to append at the end of the memory buffer.

返回值

The new size of the memory buffer.

Swoole\Buffer::clear

Reset the memory buffer.

说明

public void Swoole\Buffer::clear ( void )

参数

此函数没有参数。

Swoole\Buffer::__construct

Fixed size memory blocks allocation.

说明

public Swoole\Buffer::__construct ([ integer $size ] )

参数

size
The size of the memory to allocate.

Swoole\Buffer::__destruct

Destruct the Swoole memory buffer.

说明

public void Swoole\Buffer::__destruct ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

Swoole\Buffer::expand

Expand the size of memory buffer.

说明

public integer Swoole\Buffer::expand ( integer $size )

参数

size
The new size of the memory buffer.

返回值

The new size of the memory buffer.

Swoole\Buffer::read

Read data from the memory buffer based on offset and length.

说明

public string Swoole\Buffer::read ( integer $offset , integer $length )

参数

offset
The offset.

length
The length.

返回值

The data readed from the memory buffer.

Swoole\Buffer::recycle

Release the memory to OS which is not used by the memory buffer.

说明

public void Swoole\Buffer::recycle ( void )

参数

此函数没有参数。

Swoole\Buffer::substr

Read data from the memory buffer based on offset and length. Or remove data from the memory buffer.

说明

public string Swoole\Buffer::substr ( integer $offset [, integer $length [, bool $remove ]] )

If $remove is set to be true and $offset is set to be 0, the data will be removed from the buffer. The memory for storing the data will be released when the buffer object is deconstructed.

参数

offset
The offset.

length
The length.

remove
Whether to remove the data from the memory buffer.

返回值

The data or string readed from the memory buffer.

Swoole\Buffer::__toString

Get the string value of the memory buffer.

说明

public string Swoole\Buffer::__toString ( void )

参数

此函数没有参数。

返回值

The string value of the memory buffer.

Swoole\Buffer::write

Write data to the memory buffer. The memory allocated for the buffer will not be changed.

说明

public void Swoole\Buffer::write ( integer $offset , string $data )

参数

offset
The offset.

data
The data to write to the memory buffer.

返回值

简介

类摘要

Swoole\Channel

class Swoole\Channel {

/* 方法 */

public void __destruct ( void )

public mixed pop ( void )

public bool push ( string $data )

public array stats ( void )

}

Swoole\Channel::__construct

Construct a Swoole Channel

说明

public Swoole\Channel::__construct ( string $size )

Swoole channel is memory data structure works like Chan in Golang, implemented based on shared memory and mutex locks. It can be used as high performance message queue in memory. Construct a swoole channel with a fixed size. The minimum size of a swoole channel is 64KB. Exceptions will be thrown if there is not enough memory.

参数

size
The size of the Swoole channel.

Swoole\Channel::__destruct

Destruct a Swoole channel.

说明

public void Swoole\Channel::__destruct ( void )

参数

此函数没有参数。

Swoole\Channel::pop

Read and pop data from swoole channel.

说明

public mixed Swoole\Channel::pop ( void )

参数

此函数没有参数。

返回值

If the channel is empty, the function will return false, or return the unserialized data.

Swoole\Channel::push

Write and push data into Swoole channel.

说明

public bool Swoole\Channel::push ( string $data )

Data can be any non-empty PHP variable, the variable will be serialized if it is not string type.

If size of the data is more than 8KB, swoole channel will use temp files storage.

The function will return true if the write operation is succeeded, or return false if there is not enough space.

参数

data
The data to push into the Swoole channel.

返回值

Wheter the data is pushed into he Swoole channel.

Swoole\Channel::stats

Get stats of swoole channel.

说明

public array Swoole\Channel::stats ( void )

Get the numbers of queued elements and total size of the memory used by the queue.

参数

此函数没有参数。

返回值

The stats of the Swoole channel.

简介

类摘要

Swoole\Client

class Swoole\Client {

/* Constants */

const integer Swoole\Client::MSG_OOB = 1 ;

const integer Swoole\Client::MSG_PEEK = 2 ;

const integer Swoole\Client::MSG_DONTWAIT = 128 ;

const integer Swoole\Client::MSG_WAITALL = 64 ;

/* 属性 */

public $errCode ;

public $sock ;

public $reuse ;

public $reuseCount ;

/* 方法 */

public bool close ([ bool $force ] )

public bool connect ( string $host [, integer $port [, integer $timeout [, integer $flag ]]] )

public void __destruct ( void )

public array getpeername ( void )

public array getsockname ( void )

public bool isConnected ( void )

public void on ( string $event , callable $callback )

public void pause ( void )

public void pipe ( string $socket )

public void recv ([ string $size [, string $flag ]] )

public void resume ( void )

public integer send ( string $data [, string $flag ] )

public boolean sendfile ( string $filename [, int $offset ] )

public boolean sendto ( string $ip , integer $port , string $data )

public void set ( array $settings )

public void sleep ( void )

public void wakeup ( void )

}

属性

errCode

sock

reuse

reuseCount

预定义常量

Swoole\Client::MSG_OOB

Swoole\Client::MSG_PEEK

Swoole\Client::MSG_DONTWAIT

Swoole\Client::MSG_WAITALL

Swoole\Client::close

Close the connection established.

说明

public bool Swoole\Client::close ([ bool $force ] )

参数

force
Whether force to close the connection.

返回值

Whether the connection is closed.

Swoole\Client::connect

Connect to the remote TCP or UDP port.

说明

public bool Swoole\Client::connect ( string $host [, integer $port [, integer $timeout [, integer $flag ]]] )

参数

host
The host name of the remote address.

port
The port number of the remote address.

timeout
The timeout(second) of connect/send/recv, the dafault value is 0.1s

flag
If the type of client is UDP, the $flag means if to enable the configuration udp_connect. If the configuration udp_connect is enabled, the client will only receive the data from specified ip:port. If the type of client is TCP and the $flag is set to 1, it must use swoole_client_select to check the connection status before send/recv.

返回值

Whether the connection is established.

Swoole\Client::__construct

Create Swoole sync or async TCP/UDP client, with or without SSL.

说明

public Swoole\Client::__construct ( int $sock_type [, integer $is_async ] )

参数

sock_type
The type of socket: SWOOLE_TCP, SWOOLE_UDP, SWOOLE_ASYNC, SWOOLE_SSL, SWOOLE_KEEP.

is_async
Synchronous or asynchronous client.

Swoole\Client::__destruct

Destruct the Swoole client.

说明

public void Swoole\Client::__destruct ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

Swoole\Client::getpeername

Get the remote socket name of the connection.

说明

public array Swoole\Client::getpeername ( void )

参数

此函数没有参数。

返回值

The host and port of the remote socket.

Swoole\Client::getsockname

Get the local socket name of the connection.

说明

public array Swoole\Client::getsockname ( void )

参数

此函数没有参数。

返回值

The host and port of the local socket.

Swoole\Client::isConnected

Check if the connection is established.

说明

public bool Swoole\Client::isConnected ( void )

This method returns the connection status of application layer.

参数

此函数没有参数。

返回值

Whether the connection is established.

Swoole\Client::on

Add callback functions triggered by events.

说明

public void Swoole\Client::on ( string $event , callable $callback )

参数

event

callback

Swoole\Client::pause

Pause receiving data.

说明

public void Swoole\Client::pause ( void )

参数

此函数没有参数。

Swoole\Client::pipe

Redirect the data to another file descriptor.

说明

public void Swoole\Client::pipe ( string $socket )

参数

socket

Swoole\Client::recv

Receive data from the remote socket.

说明

public void Swoole\Client::recv ([ string $size [, string $flag ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

size

flag

返回值

Swoole\Client::resume

Resume receiving data.

说明

public void Swoole\Client::resume ( void )

参数

此函数没有参数。

Swoole\Client::send

Send data to the remote TCP socket.

说明

public integer Swoole\Client::send ( string $data [, string $flag ] )

参数

data
The data to send which can be string or binary

flag

返回值

If the client sends data successfully, it returns the length of data sent. Or it returns false and sets $swoole_client->errCode. For sync client, there is no limit for the data to send. For async client, The limit for the data to send is socket_buffer_size.

Swoole\Client::sendfile

Send file to the remote TCP socket.

说明

public boolean Swoole\Client::sendfile ( string $filename [, int $offset ] )

This is a wrapper of the Linux sendfile system call.

参数

filename
File path of the file to send.

offset
Offset of the file to send

返回值

Swoole\Client::sendto

Send data to the remote UDP address.

说明

public boolean Swoole\Client::sendto ( string $ip , integer $port , string $data )

The swoole client should be type of SWOOLE_SOCK_UDP or SWOOLE_SOCK_UDP6.

参数

ip
The IP address of remote host, IPv4 or IPv6.

port
The port number of remote host.

data
The data to send which should be less-than 64K.

返回值

Swoole\Client::set

Set the Swoole client parameters before the connection is established.

说明

public void Swoole\Client::set ( array $settings )

参数

settings

返回值

Swoole\Client::sleep

Remove the TCP client from system event loop.

说明

public void Swoole\Client::sleep ( void )

Remove the TCP client from system event loop.

参数

此函数没有参数。

返回值

Swoole\Client::wakeup

Add the TCP client back into the system event loop.

说明

public void Swoole\Client::wakeup ( void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Connection\Iterator

class Swoole\Connection\Iterator implements Iterator , Countable , ArrayAccess {

/* 方法 */

public int count ( void )

public Connection current ( void )

public int key ( void )

public Connection next ( void )

public boolean offsetExists ( int $index )

public Connection offsetGet ( string $index )

public void offsetSet ( int $offset , mixed $connection )

public void offsetUnset ( int $offset )

public void rewind ( void )

public boolean valid ( void )

}

Swoole\Connection\Iterator::count

Count connections.

说明

public int Swoole\Connection\Iterator::count ( void )

Gets the number of connections.

参数

此函数没有参数。

返回值

The number of connections.

Swoole\Connection\Iterator::current

Return current connection entry.

说明

public Connection Swoole\Connection\Iterator::current ( void )

Get current connection entry.

参数

此函数没有参数。

返回值

The current connection entry.

Swoole\Connection\Iterator::key

Return key of the current connection.

说明

public int Swoole\Connection\Iterator::key ( void )

This function returns key of the current connection.

参数

此函数没有参数。

返回值

Key of the current connection.

Swoole\Connection\Iterator::next

Move to the next connection.

说明

public Connection Swoole\Connection\Iterator::next ( void )

The iterator to the next connection.

参数

此函数没有参数。

返回值

Swoole\Connection\Iterator::offsetExists

Check if offet exists.

说明

public boolean Swoole\Connection\Iterator::offsetExists ( int $index )

Check if offset exists.

参数

index
The offset being checked.

返回值

Returns TRUE if the offset exists, otherwise FALSE.

Swoole\Connection\Iterator::offsetGet

Offset to retrieve.

说明

public Connection Swoole\Connection\Iterator::offsetGet ( string $index )

Return the connection at specified offset.

参数

index
The offset to retrieve.

返回值

Swoole\Connection\Iterator::offsetSet

Assign a Connection to the specified offset.

说明

public void Swoole\Connection\Iterator::offsetSet ( int $offset , mixed $connection )

Assign a Connection to the specified offset.

参数

offset
The offset to assign the Connection to.

connection
The connection to set.

返回值

Swoole\Connection\Iterator::offsetUnset

Unset an offset.

说明

public void Swoole\Connection\Iterator::offsetUnset ( int $offset )

Unsets an offset.

参数

offset
The offset to unset.

返回值

Swoole\Connection\Iterator::rewind

Rewinds iterator

说明

public void Swoole\Connection\Iterator::rewind ( void )

参数

此函数没有参数。

返回值

Swoole\Connection\Iterator::valid

Check if current position is valid.

说明

public boolean Swoole\Connection\Iterator::valid ( void )

Checks if the current position is valid.

参数

此函数没有参数。

返回值

Returns TRUE if the current iterator position is valid, otherwise FALSE.

简介

类摘要

Swoole\Coroutine

class Swoole\Coroutine {

/* 方法 */

public static mixed call_user_func_array ( callable $callback , array $param_array )

public static mixed call_user_func ( callable $callback [, mixed $... ] )

public static ReturnType cli_wait ( void )

public static ReturnType create ( void )

public static ReturnType getuid ( void )

public static ReturnType resume ( void )

public static ReturnType suspend ( void )

}

Swoole\Coroutine::call_user_func_array

Call a callback with an array of parameters

说明

public static mixed Swoole\Coroutine::call_user_func_array ( callable $callback , array $param_array )

Calls the callback given by the first parameter with the parameters in param_array.

参数

callback
The callable to be called.

param_array
Zero or more parameters in the array to be passed to the callback.

返回值

Swoole\Coroutine::call_user_func

Call a callback given by the first parameter

说明

public static mixed Swoole\Coroutine::call_user_func ( callable $callback [, mixed $... ] )

Calls the callback given by the first parameter and passes the remaining parameters as arguments.

参数

callback
The callable to be called.

...
Zero or more parameters to be passed to the callback.

返回值

Swoole\Coroutine::cli_wait

Description

说明

public static ReturnType Swoole\Coroutine::cli_wait ( void )

参数

此函数没有参数。

返回值

Swoole\Coroutine::create

Description

说明

public static ReturnType Swoole\Coroutine::create ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::getuid

Description

说明

public static ReturnType Swoole\Coroutine::getuid ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::resume

Description

说明

public static ReturnType Swoole\Coroutine::resume ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Coroutine::suspend

Description

说明

public static ReturnType Swoole\Coroutine::suspend ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Event

class Swoole\Event {

/* 方法 */

public static boolean add ( int $fd , callable $read_callback [, callable $write_callback [, string $events ]] )

public static void defer ( mixed $callback )

public static boolean del ( string $fd )

public static void exit ( void )

public static boolean set ( int $fd [, string $read_callback [, string $write_callback [, string $events ]]] )

public static void wait ( void )

public static void write ( string $fd , string $data )

}

Swoole\Event::add

Add new callback functions of a socket into the EventLoop.

说明

public static boolean Swoole\Event::add ( int $fd , callable $read_callback [, callable $write_callback [, string $events ]] )

参数

fd

read_callback

write_callback

events

返回值

Swoole\Event::defer

Add a callback function to the next event loop.

说明

public static void Swoole\Event::defer ( mixed $callback )

参数

callback

返回值

Swoole\Event::del

Remove all event callback functions of a socket.

说明

public static boolean Swoole\Event::del ( string $fd )

参数

fd

返回值

Swoole\Event::exit

Exit the eventloop, only available at client side.

说明

public static void Swoole\Event::exit ( void )

参数

此函数没有参数。

返回值

Swoole\Event::set

Update the event callback functions of a socket.

说明

public static boolean Swoole\Event::set ( int $fd [, string $read_callback [, string $write_callback [, string $events ]]] )

参数

fd

read_callback

write_callback

events

返回值

Swoole\Event::wait

Description

说明

public static void Swoole\Event::wait ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\Event::write

Write data to the socket.

说明

public static void Swoole\Event::write ( string $fd , string $data )

参数

fd

data

返回值

简介

类摘要

Swoole\Exception

class Swoole\Exception extends Exception implements Throwable {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

}

简介

类摘要

Swoole\Http\Client

class Swoole\Http\Client {

/* 属性 */

public $errCode ;

public $sock ;

/* 方法 */

public void addFile ( string $path , string $name [, string $type [, string $filename [, string $offset ]]] )

public void close ( void )

public void __destruct ( void )

public void download ( string $path , string $file , callable $callback [, integer $offset ] )

public void execute ( string $path , string $callback )

public void get ( string $path , callable $callback )

public boolean isConnected ( void )

public void on ( string $event_name , callable $callback )

public void post ( string $path , string $data , callable $callback )

public void push ( string $data [, string $opcode [, string $finish ]] )

public void set ( array $settings )

public void setCookies ( array $cookies )

public ReturnType setData ( string $data )

public void setHeaders ( array $headers )

public void setMethod ( string $method )

public void upgrade ( string $path , string $callback )

}

属性

errCode

sock

Swoole\Http\Client::addFile

Add a file to the post form.

说明

public void Swoole\Http\Client::addFile ( string $path , string $name [, string $type [, string $filename [, string $offset ]]] )

参数

path

name

type

filename

offset

返回值

Swoole\Http\Client::close

Close the http connection.

说明

public void Swoole\Http\Client::close ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::__construct

Construct the async HTTP client.

说明

public Swoole\Http\Client::__construct ( string $host [, string $port [, boolean $ssl ]] )

参数

host
The hostname of the remote host.

port
The port number of the remote host.

ssl
Whether to enable SSL.

Swoole\Http\Client::__destruct

Destruct the HTTP client.

说明

public void Swoole\Http\Client::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::download

Download a file from the remote server.

说明

public void Swoole\Http\Client::download ( string $path , string $file , callable $callback [, integer $offset ] )

参数

path

file

callback

offset

返回值

Swoole\Http\Client::execute

Send the HTTP request after setting the parameters.

说明

public void Swoole\Http\Client::execute ( string $path , string $callback )

参数

path

callback

返回值

Swoole\Http\Client::get

Send GET http request to the remote server.

说明

public void Swoole\Http\Client::get ( string $path , callable $callback )

参数

path

callback

返回值

Swoole\Http\Client::isConnected

Check if the HTTP connection is connected.

说明

public boolean Swoole\Http\Client::isConnected ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Client::on

Register callback function by event name.

说明

public void Swoole\Http\Client::on ( string $event_name , callable $callback )

参数

event_name

callback

返回值

Swoole\Http\Client::post

Send POST http request to the remote server.

说明

public void Swoole\Http\Client::post ( string $path , string $data , callable $callback )

参数

path

data

callback

返回值

Swoole\Http\Client::push

Push data to websocket client.

说明

public void Swoole\Http\Client::push ( string $data [, string $opcode [, string $finish ]] )

参数

data

opcode

finish

返回值

Swoole\Http\Client::set

Update the HTTP client paramters.

说明

public void Swoole\Http\Client::set ( array $settings )

参数

settings

返回值

Swoole\Http\Client::setCookies

Set the http request cookies.

说明

public void Swoole\Http\Client::setCookies ( array $cookies )

参数

cookies

返回值

Swoole\Http\Client::setData

Set the HTTP request body data.

说明

public ReturnType Swoole\Http\Client::setData ( string $data )

The HTTP method will be changed to be POST.

参数

data

返回值

Swoole\Http\Client::setHeaders

Set the HTTP request headers.

说明

public void Swoole\Http\Client::setHeaders ( array $headers )

参数

headers

返回值

Swoole\Http\Client::setMethod

Set the HTTP request method.

说明

public void Swoole\Http\Client::setMethod ( string $method )

参数

method

返回值

Swoole\Http\Client::upgrade

Upgrade to websocket protocol.

说明

public void Swoole\Http\Client::upgrade ( string $path , string $callback )

参数

path

callback

返回值

简介

类摘要

Swoole\Http\Request

class Swoole\Http\Request {

/* 方法 */

public void __destruct ( void )

public string rawcontent ( void )

}

Swoole\Http\Request::__destruct

Destruct the HTTP request.

说明

public void Swoole\Http\Request::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Request::rawcontent

Get the raw HTTP POST body.

说明

public string Swoole\Http\Request::rawcontent ( void )

This method is used for the POST data which isn't in the form of `application/x-www-form-urlencoded`.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Http\Response

class Swoole\Http\Response {

/* 方法 */

public string cookie ( string $name [, string $value [, string $expires [, string $path [, string $domain [, string $secure [, string $httponly ]]]]]] )

public void __destruct ( void )

public void end ([ string $content ] )

public ReturnType gzip ([ string $compress_level ] )

public void header ( string $key , string $value [, string $ucwords ] )

public ReturnType initHeader ( void )

public ReturnType rawcookie ( string $name [, string $value [, string $expires [, string $path [, string $domain [, string $secure [, string $httponly ]]]]]] )

public ReturnType sendfile ( string $filename [, int $offset ] )

public ReturnType status ( string $http_code )

public void write ( string $content )

}

Swoole\Http\Response::cookie

Set the cookies of the HTTP response.

说明

public string Swoole\Http\Response::cookie ( string $name [, string $value [, string $expires [, string $path [, string $domain [, string $secure [, string $httponly ]]]]]] )

参数

name

value

expires

path

domain

secure

httponly

返回值

Swoole\Http\Response::__destruct

Destruct the HTTP response.

说明

public void Swoole\Http\Response::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Http\Response::end

Send data for the HTTP request and finish the response.

说明

public void Swoole\Http\Response::end ([ string $content ] )

参数

content

返回值

Swoole\Http\Response::gzip

Enable the gzip of response content.

说明

public ReturnType Swoole\Http\Response::gzip ([ string $compress_level ] )

The header about Content-Encoding will be added automatically.

参数

compress_level

返回值

Swoole\Http\Response::header

Set the HTTP response headers.

说明

public void Swoole\Http\Response::header ( string $key , string $value [, string $ucwords ] )

参数

key

value

ucwords

返回值

Swoole\Http\Response::initHeader

Init the HTTP response header.

说明

public ReturnType Swoole\Http\Response::initHeader ( void )

Init the HTTP response header.

参数

此函数没有参数。

返回值

Swoole\Http\Response::rawcookie

Set the raw cookies to the HTTP response.

说明

public ReturnType Swoole\Http\Response::rawcookie ( string $name [, string $value [, string $expires [, string $path [, string $domain [, string $secure [, string $httponly ]]]]]] )

参数

name

value

expires

path

domain

secure

httponly

返回值

Swoole\Http\Response::sendfile

Send file through the HTTP response.

说明

public ReturnType Swoole\Http\Response::sendfile ( string $filename [, int $offset ] )

Send file through the HTTP response.

参数

filename

offset

返回值

Swoole\Http\Response::status

Set the status code of the HTTP response.

说明

public ReturnType Swoole\Http\Response::status ( string $http_code )

Set the status code of the HTTP response.

参数

http_code

返回值

Swoole\Http\Response::write

Append HTTP body content to the HTTP response.

说明

public void Swoole\Http\Response::write ( string $content )

Append HTTP body content to the HTTP response.

参数

content

返回值

简介

类摘要

Swoole\Http\Server

class Swoole\Http\Server extends Swoole\Server {

/* 方法 */

public void on ( string $event_name , callable $callback )

public void start ( void )

/* 继承的方法 */

public void Swoole\Server::addlistener ( string $host , integer $port , string $socket_type )

public boolean Swoole\Server::addProcess ( swoole_process $process )

public ReturnType Swoole\Server::after ( integer $after_time_ms , callable $callback [, string $param ] )

public boolean Swoole\Server::bind ( integer $fd , integer $uid )

public void Swoole\Server::clearTimer ( integer $timer_id )

void swoole_timer_clear ( integer $timer_id )

public boolean Swoole\Server::close ( integer $fd [, boolean $reset ] )

public boolean Swoole\Server::confirm ( integer $fd )

public array Swoole\Server::connection_info ( integer $fd [, integer $reactor_id ] )

public array Swoole\Server::connection_list ( integer $start_fd [, integer $pagesize ] )

public void Swoole\Server::defer ( callable $callback )

public boolean Swoole\Server::exist ( integer $fd )

public void Swoole\Server::finish ( string $data )

public ReturnType Swoole\Server::getClientInfo ( integer $fd [, integer $reactor_id ] )

public array Swoole\Server::getClientList ( integer $start_fd [, integer $pagesize ] )

public integer Swoole\Server::getLastError ( void )

public mixed Swoole\Server::heartbeat ( boolean $if_close_connection )

public boolean Swoole\Server::listen ( string $host , integer $port , string $socket_type )

public void Swoole\Server::on ( string $event_name , callable $callback )

public void Swoole\Server::pause ( integer $fd )

public void Swoole\Server::protect ( integer $fd [, boolean $is_protected ] )

public boolean Swoole\Server::reload ( void )

public void Swoole\Server::resume ( integer $fd )

public boolean Swoole\Server::send ( integer $fd , string $data [, integer $reactor_id ] )

public boolean Swoole\Server::sendfile ( integer $fd , string $filename [, integer $offset ] )

public boolean Swoole\Server::sendMessage ( integer $worker_id , string $data )

public boolean Swoole\Server::sendto ( string $ip , integer $port , string $data [, string $server_socket ] )

public boolean Swoole\Server::sendwait ( integer $fd , string $data )

public ReturnType Swoole\Server::set ( array $settings )

public void Swoole\Server::shutdown ( void )

public void Swoole\Server::start ( void )

public array Swoole\Server::stats ( void )

public boolean Swoole\Server::stop ([ integer $worker_id ] )

public mixed Swoole\Server::task ( string $data [, integer $dst_worker_id [, callable $callback ]] )

public void Swoole\Server::taskwait ( string $data [, float $timeout [, integer $worker_id ]] )

public void Swoole\Server::taskWaitMulti ( array $tasks [, double $timeout_ms ] )

public void Swoole\Server::tick ( integer $interval_ms , callable $callback )

}

Swoole\Http\Server::on

Bind callback function to HTTP server by event name.

说明

public void Swoole\Http\Server::on ( string $event_name , callable $callback )

Bind callback function to HTTP server by event name.

参数

event_name

callback

返回值

Swoole\Http\Server::start

Start the swoole http server.

说明

public void Swoole\Http\Server::start ( void )

Start the swoole http server.

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Lock

class Swoole\Lock {

/* 方法 */

public void __destruct ( void )

public void lock_read ( void )

public void lock ( void )

public void trylock_read ( void )

public void trylock ( void )

public void unlock ( void )

}

Swoole\Lock::__construct

Construct a memory lock.

说明

public Swoole\Lock::__construct ([ string $type [, string $file_lock_location ]] )

Swoole lock is used for data synchronization between multiple theads or processes.

参数

type

file_lock_location

Swoole\Lock::__destruct

Destory a Swoole memory lock.

说明

public void Swoole\Lock::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Lock::lock_read

Lock a read-write lock for reading.

说明

public void Swoole\Lock::lock_read ( void )

Lock a read-write lock for reading.

参数

此函数没有参数。

返回值

Swoole\Lock::lock

Try to acquire the lock. It will block if the lock is not available.

说明

public void Swoole\Lock::lock ( void )

参数

此函数没有参数。

返回值

Swoole\Lock::trylock_read

Try to lock a read-write lock for reading and return straight away even the lock is not available.

说明

public void Swoole\Lock::trylock_read ( void )

参数

此函数没有参数。

返回值

Swoole\Lock::trylock

Try to acquire the lock and return straight away even the lock is not available.

说明

public void Swoole\Lock::trylock ( void )

参数

此函数没有参数。

返回值

Swoole\Lock::unlock

Release the lock.

说明

public void Swoole\Lock::unlock ( void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Mmap

class Swoole\Mmap {

/* 方法 */

public static ReturnType open ( string $filename [, string $size [, string $offset ]] )

}

Swoole\Mmap::open

Map a file into memory and return the stream resource which can be used by PHP stream operations.

说明

public static ReturnType Swoole\Mmap::open ( string $filename [, string $size [, string $offset ]] )

参数

filename

size

offset

返回值

简介

类摘要

Swoole\MySQL

class Swoole\MySQL {

/* 方法 */

public void close ( void )

public void connect ( array $server_config , callable $callback )

public void __destruct ( void )

public ReturnType getBuffer ( void )

public void on ( string $event_name , callable $callback )

public ReturnType query ( string $sql , callable $callback )

}

Swoole\MySQL::close

Close the async MySQL connection.

说明

public void Swoole\MySQL::close ( void )

参数

此函数没有参数。

返回值

Swoole\MySQL::connect

Connect to the remote MySQL server.

说明

public void Swoole\MySQL::connect ( array $server_config , callable $callback )

Connect to the remote MySQL server.

参数

server_config

callback

返回值

Swoole\MySQL::__construct

Construct an async MySQL client.

说明

public Swoole\MySQL::__construct ( void )

Construct an async MySQL client.

参数

此函数没有参数。

Swoole\MySQL::__destruct

Destory the async MySQL client.

说明

public void Swoole\MySQL::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\MySQL::getBuffer

Description

说明

public ReturnType Swoole\MySQL::getBuffer ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Swoole\MySQL::on

Register callback function based on event name.

说明

public void Swoole\MySQL::on ( string $event_name , callable $callback )

Register callback function based on event name, current only 'close' event is supported.

参数

event_name

callback

返回值

Swoole\MySQL::query

Run the SQL query.

说明

public ReturnType Swoole\MySQL::query ( string $sql , callable $callback )

参数

sql

callback

返回值

简介

类摘要

Swoole\MySQL\Exception

class Swoole\MySQL\Exception extends Exception implements Throwable {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

}

简介

类摘要

Swoole\Process

class Swoole\Process {

/* Constants */

const integer Swoole\Process::IPC_NOWAIT = 256 ;

/* 方法 */

public static void alarm ( integer $interval_usec )

public void close ( void )

public static void daemon ([ boolean $nochdir [, boolean $noclose ]] )

public void __destruct ( void )

public ReturnType exec ( string $exec_file , string $args )

public void exit ([ string $exit_code ] )

public void freeQueue ( void )

public static void kill ( integer $pid [, string $signal_no ] )

public void name ( string $process_name )

public mixed pop ([ integer $maxsize ] )

public boolean push ( string $data )

public string read ([ integer $maxsize ] )

public static void signal ( string $signal_no , callable $callback )

public void start ( void )

public array statQueue ( void )

public boolean useQueue ( integer $key [, integer $mode ] )

public static array wait ([ boolean $blocking ] )

public integer write ( string $data )

}

预定义常量

Swoole\Process::IPC_NOWAIT

Swoole\Process::alarm

High precision timer which triggers signal with fixed interval.

说明

public static void Swoole\Process::alarm ( integer $interval_usec )

参数

interval_usec

返回值

Swoole\Process::close

Close the pipe to the child process.

说明

public void Swoole\Process::close ( void )

Close the pipe to the child process.

参数

此函数没有参数。

返回值

Swoole\Process::__construct

Construct a process.

说明

public Swoole\Process::__construct ( callable $callback [, boolean $redirect_stdin_and_stdout [, integer $pipe_type ]] )

参数

callback

redirect_stdin_and_stdout

pipe_type

Swoole\Process::daemon

Change the process to be a daemon process.

说明

public static void Swoole\Process::daemon ([ boolean $nochdir [, boolean $noclose ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

nochdir

noclose

返回值

Swoole\Process::__destruct

Destory the process.

说明

public void Swoole\Process::__destruct ( void )

参数

此函数没有参数。

返回值

Swoole\Process::exec

Execute system commands.

说明

public ReturnType Swoole\Process::exec ( string $exec_file , string $args )

The process will be replaced to be the system command process, but the pipe to the parent process will be kept.

参数

exec_file

args

返回值

Swoole\Process::exit

Stop the child processes.

说明

public void Swoole\Process::exit ([ string $exit_code ] )

参数

exit_code

返回值

Swoole\Process::freeQueue

Destroy the message queue created by swoole_process::useQueue.

说明

public void Swoole\Process::freeQueue ( void )

参数

此函数没有参数。

返回值

Swoole\Process::kill

Send signal to the child process.

说明

public static void Swoole\Process::kill ( integer $pid [, string $signal_no ] )

Send signal to the child process.

参数

pid

signal_no

返回值

Swoole\Process::name

Set name of the process.

说明

public void Swoole\Process::name ( string $process_name )

参数

process_name

返回值

Swoole\Process::pop

Read and pop data from the message queue.

说明

public mixed Swoole\Process::pop ([ integer $maxsize ] )

参数

maxsize

返回值

Swoole\Process::push

Write and push data into the message queue.

说明

public boolean Swoole\Process::push ( string $data )

参数

data

返回值

Swoole\Process::read

Read data sending to the process.

说明

public string Swoole\Process::read ([ integer $maxsize ] )

参数

maxsize

返回值

Swoole\Process::signal

Send signal to the child processes.

说明

public static void Swoole\Process::signal ( string $signal_no , callable $callback )

参数

signal_no

callback

返回值

If signal sent successfully, it returns TRUE, otherwise it returns FALSE.

Swoole\Process::start

Start the process.

说明

public void Swoole\Process::start ( void )

参数

此函数没有参数。

返回值

Swoole\Process::statQueue

Get the stats of the message queue used as the communication method between processes.

说明

public array Swoole\Process::statQueue ( void )

参数

此函数没有参数。

返回值

The array of status of the message queue.

Swoole\Process::useQueue

Create a message queue as the communication method between the parent process and child processes.

说明

public boolean Swoole\Process::useQueue ( integer $key [, integer $mode ] )

参数

key

mode

返回值

Swoole\Process::wait

Wait for the events of child processes.

说明

public static array Swoole\Process::wait ([ boolean $blocking ] )

参数

blocking

返回值

Swoole\Process::write

Write data into the pipe and communicate with the parent process or child processes.

说明

public integer Swoole\Process::write ( string $data )

参数

data

返回值

简介

类摘要

Swoole\Redis\Server

class Swoole\Redis\Server extends Swoole\Server {

/* Constants */

const integer Swoole\Redis\Server::NIL = 1 ;

const integer Swoole\Redis\Server::ERROR = 0 ;

const integer Swoole\Redis\Server::STATUS = 2 ;

const integer Swoole\Redis\Server::INT = 3 ;

const integer Swoole\Redis\Server::STRING = 4 ;

const integer Swoole\Redis\Server::SET = 5 ;

const integer Swoole\Redis\Server::MAP = 6 ;

/* 方法 */

public static ReturnType format ( string $type [, string $value ] )

public ReturnType setHandler ( string $command , string $callback [, string $number_of_string_param [, string $type_of_array_param ]] )

public ReturnType start ( void )

/* 继承的方法 */

public void Swoole\Server::addlistener ( string $host , integer $port , string $socket_type )

public boolean Swoole\Server::addProcess ( swoole_process $process )

public ReturnType Swoole\Server::after ( integer $after_time_ms , callable $callback [, string $param ] )

public boolean Swoole\Server::bind ( integer $fd , integer $uid )

public void Swoole\Server::clearTimer ( integer $timer_id )

void swoole_timer_clear ( integer $timer_id )

public boolean Swoole\Server::close ( integer $fd [, boolean $reset ] )

public boolean Swoole\Server::confirm ( integer $fd )

public array Swoole\Server::connection_info ( integer $fd [, integer $reactor_id ] )

public array Swoole\Server::connection_list ( integer $start_fd [, integer $pagesize ] )

public void Swoole\Server::defer ( callable $callback )

public boolean Swoole\Server::exist ( integer $fd )

public void Swoole\Server::finish ( string $data )

public ReturnType Swoole\Server::getClientInfo ( integer $fd [, integer $reactor_id ] )

public array Swoole\Server::getClientList ( integer $start_fd [, integer $pagesize ] )

public integer Swoole\Server::getLastError ( void )

public mixed Swoole\Server::heartbeat ( boolean $if_close_connection )

public boolean Swoole\Server::listen ( string $host , integer $port , string $socket_type )

public void Swoole\Server::on ( string $event_name , callable $callback )

public void Swoole\Server::pause ( integer $fd )

public void Swoole\Server::protect ( integer $fd [, boolean $is_protected ] )

public boolean Swoole\Server::reload ( void )

public void Swoole\Server::resume ( integer $fd )

public boolean Swoole\Server::send ( integer $fd , string $data [, integer $reactor_id ] )

public boolean Swoole\Server::sendfile ( integer $fd , string $filename [, integer $offset ] )

public boolean Swoole\Server::sendMessage ( integer $worker_id , string $data )

public boolean Swoole\Server::sendto ( string $ip , integer $port , string $data [, string $server_socket ] )

public boolean Swoole\Server::sendwait ( integer $fd , string $data )

public ReturnType Swoole\Server::set ( array $settings )

public void Swoole\Server::shutdown ( void )

public void Swoole\Server::start ( void )

public array Swoole\Server::stats ( void )

public boolean Swoole\Server::stop ([ integer $worker_id ] )

public mixed Swoole\Server::task ( string $data [, integer $dst_worker_id [, callable $callback ]] )

public void Swoole\Server::taskwait ( string $data [, float $timeout [, integer $worker_id ]] )

public void Swoole\Server::taskWaitMulti ( array $tasks [, double $timeout_ms ] )

public void Swoole\Server::tick ( integer $interval_ms , callable $callback )

}

预定义常量

Swoole\Redis\Server::NIL

Swoole\Redis\Server::ERROR

Swoole\Redis\Server::STATUS

Swoole\Redis\Server::INT

Swoole\Redis\Server::STRING

Swoole\Redis\Server::SET

Swoole\Redis\Server::MAP

Swoole\Redis\Server::format

Description

说明

public static ReturnType Swoole\Redis\Server::format ( string $type [, string $value ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

type

value

返回值

Swoole\Redis\Server::setHandler

Description

说明

public ReturnType Swoole\Redis\Server::setHandler ( string $command , string $callback [, string $number_of_string_param [, string $type_of_array_param ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

command

callback

number_of_string_param

type_of_array_param

返回值

Swoole\Redis\Server::start

Description

说明

public ReturnType Swoole\Redis\Server::start ( void )

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Serialize

class Swoole\Serialize {

/* 方法 */

public static ReturnType pack ( string $data [, int $is_fast ] )

public static ReturnType unpack ( string $data [, string $args ] )

}

Swoole\Serialize::pack

Serialize the data.

说明

public static ReturnType Swoole\Serialize::pack ( string $data [, int $is_fast ] )

Swoole provides a fast and high performance serialization module.

参数

data

is_fast

返回值

Swoole\Serialize::unpack

Unserialize the data.

说明

public static ReturnType Swoole\Serialize::unpack ( string $data [, string $args ] )

Unserialize the data.

参数

string

args

返回值

简介

类摘要

Swoole\Server

class Swoole\Server {

/* 方法 */

public void addlistener ( string $host , integer $port , string $socket_type )

public boolean addProcess ( swoole_process $process )

public ReturnType after ( integer $after_time_ms , callable $callback [, string $param ] )

public boolean bind ( integer $fd , integer $uid )

public void clearTimer ( integer $timer_id )

void swoole_timer_clear ( integer $timer_id )

public boolean close ( integer $fd [, boolean $reset ] )

public boolean confirm ( integer $fd )

public array connection_info ( integer $fd [, integer $reactor_id ] )

public array connection_list ( integer $start_fd [, integer $pagesize ] )

public void defer ( callable $callback )

public boolean exist ( integer $fd )

public void finish ( string $data )

public ReturnType getClientInfo ( integer $fd [, integer $reactor_id ] )

public array getClientList ( integer $start_fd [, integer $pagesize ] )

public integer getLastError ( void )

public mixed heartbeat ( boolean $if_close_connection )

public boolean listen ( string $host , integer $port , string $socket_type )

public void on ( string $event_name , callable $callback )

public void pause ( integer $fd )

public void protect ( integer $fd [, boolean $is_protected ] )

public boolean reload ( void )

public void resume ( integer $fd )

public boolean send ( integer $fd , string $data [, integer $reactor_id ] )

public boolean sendfile ( integer $fd , string $filename [, integer $offset ] )

public boolean sendMessage ( integer $worker_id , string $data )

public boolean sendto ( string $ip , integer $port , string $data [, string $server_socket ] )

public boolean sendwait ( integer $fd , string $data )

public ReturnType set ( array $settings )

public void shutdown ( void )

public void start ( void )

public array stats ( void )

public boolean stop ([ integer $worker_id ] )

public mixed task ( string $data [, integer $dst_worker_id [, callable $callback ]] )

public void taskwait ( string $data [, float $timeout [, integer $worker_id ]] )

public void taskWaitMulti ( array $tasks [, double $timeout_ms ] )

public void tick ( integer $interval_ms , callable $callback )

}

Swoole\Server::addlistener

Add a new listener to the server.

说明

public void Swoole\Server::addlistener ( string $host , integer $port , string $socket_type )

参数

host

port

socket_type

返回值

Swoole\Server::addProcess

Add a user defined swoole_process to the server.

说明

public boolean Swoole\Server::addProcess ( swoole_process $process )

参数

process

返回值

Swoole\Server::after

Trigger a callback function after a period of time.

说明

public ReturnType Swoole\Server::after ( integer $after_time_ms , callable $callback [, string $param ] )

参数

after_time_ms

callback

param

返回值

Swoole\Server::bind

Bind the connection to a user defined user ID.

说明

public boolean Swoole\Server::bind ( integer $fd , integer $uid )

参数

fd

uid

返回值

Swoole\Server::clearTimer

swoole_timer_clear

Stop and destory a timer.

说明

面向对象风格 (method):

public void Swoole\Server::clearTimer ( integer $timer_id )

过程化风格:

void swoole_timer_clear ( integer $timer_id )

Stop and destory a timer

参数

timer_id

返回值

Swoole\Server::close

Close a connection to the client.

说明

public boolean Swoole\Server::close ( integer $fd [, boolean $reset ] )

参数

fd

reset

返回值

Swoole\Server::confirm

Check status of the connection.

说明

public boolean Swoole\Server::confirm ( integer $fd )

参数

fd

返回值

Swoole\Server::connection_info

Get the connection info by file description.

说明

public array Swoole\Server::connection_info ( integer $fd [, integer $reactor_id ] )

参数

fd

reactor_id

返回值

Swoole\Server::connection_list

Get all of the established connections.

说明

public array Swoole\Server::connection_list ( integer $start_fd [, integer $pagesize ] )

参数

start_fd

pagesize

返回值

Swoole\Server::__construct

Construct a Swoole server.

说明

public Swoole\Server::__construct ( string $host [, integer $port [, integr $mode [, integer $sock_type ]]] )

参数

host

port

mode

sock_type

Swoole\Server::defer

Delay execution of the callback function at the end of current EventLoop.

说明

public void Swoole\Server::defer ( callable $callback )

参数

callback

返回值

Swoole\Server::exist

Check if the connection is existed.

说明

public boolean Swoole\Server::exist ( integer $fd )

参数

fd

返回值

Swoole\Server::finish

Used in task process for sending result to the worker process when the task is finished.

说明

public void Swoole\Server::finish ( string $data )

参数

data

返回值

Swoole\Server::getClientInfo

Get the connection info by file description.

说明

public ReturnType Swoole\Server::getClientInfo ( integer $fd [, integer $reactor_id ] )

参数

fd

reactor_id

返回值

Swoole\Server::getClientList

Get all of the established connections.

说明

public array Swoole\Server::getClientList ( integer $start_fd [, integer $pagesize ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

start_fd

pagesize

返回值

Swoole\Server::getLastError

Get the error code of the most recent error.

说明

public integer Swoole\Server::getLastError ( void )

参数

此函数没有参数。

返回值

Swoole\Server::heartbeat

Check all the connections on the server.

说明

public mixed Swoole\Server::heartbeat ( boolean $if_close_connection )

参数

if_close_connection

返回值

Swoole\Server::listen

Listen on the given IP and port, socket type.

说明

public boolean Swoole\Server::listen ( string $host , integer $port , string $socket_type )

参数

host

port

socket_type

返回值

Swoole\Server::on

Register a callback function by event name.

说明

public void Swoole\Server::on ( string $event_name , callable $callback )

参数

event_name

callback

返回值

Swoole\Server::pause

Stop receiving data from the connection.

说明

public void Swoole\Server::pause ( integer $fd )

参数

fd

返回值

Swoole\Server::protect

Set the connection to be protected mode.

说明

public void Swoole\Server::protect ( integer $fd [, boolean $is_protected ] )

参数

fd

is_protected

返回值

Swoole\Server::reload

Restart all the worker process.

说明

public boolean Swoole\Server::reload ( void )

参数

此函数没有参数。

返回值

Swoole\Server::resume

Start receving data from the connection.

说明

public void Swoole\Server::resume ( integer $fd )

参数

fd

返回值

Swoole\Server::send

Send data to the client.

说明

public boolean Swoole\Server::send ( integer $fd , string $data [, integer $reactor_id ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

data

reactor_id

返回值

Swoole\Server::sendfile

Send file to the connection.

说明

public boolean Swoole\Server::sendfile ( integer $fd , string $filename [, integer $offset ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

filename

offset

返回值

Swoole\Server::sendMessage

Send message to worker processes by ID.

说明

public boolean Swoole\Server::sendMessage ( integer $worker_id , string $data )

参数

dst_worker_id

data

返回值

Swoole\Server::sendto

Send data to the remote UDP address.

说明

public boolean Swoole\Server::sendto ( string $ip , integer $port , string $data [, string $server_socket ] )

参数

ip

port

data

server_socket

返回值

Swoole\Server::sendwait

Send data to the remote socket in the blocking way.

说明

public boolean Swoole\Server::sendwait ( integer $fd , string $data )

Warning

本函数还未编写文档,仅有参数列表。

参数

fd

data

返回值

Swoole\Server::set

Set the runtime settings of the swoole server.

说明

public ReturnType Swoole\Server::set ( array $settings )

Set the runtime settings of the swoole server. The settings can be accessed by $server->setting when the swoole server has started.

参数

settings

返回值

Swoole\Server::shutdown

Shutdown the master server process, this function can be called in worker processes.

说明

public void Swoole\Server::shutdown ( void )

参数

此函数没有参数。

返回值

Swoole\Server::start

Start the Swoole server.

说明

public void Swoole\Server::start ( void )

参数

此函数没有参数。

返回值

Swoole\Server::stats

Get the stats of the Swoole server.

说明

public array Swoole\Server::stats ( void )

参数

此函数没有参数。

返回值

Swoole\Server::stop

Stop the Swoole server.

说明

public boolean Swoole\Server::stop ([ integer $worker_id ] )

参数

worker_id

返回值

Swoole\Server::task

Send data to the task worker processes.

说明

public mixed Swoole\Server::task ( string $data [, integer $dst_worker_id [, callable $callback ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

data

dst_worker_id

callback

返回值

Swoole\Server::taskwait

Send data to the task worker processes in blocking way.

说明

public void Swoole\Server::taskwait ( string $data [, float $timeout [, integer $worker_id ]] )

Warning

本函数还未编写文档,仅有参数列表。

参数

data

timeout

worker_id

返回值

Swoole\Server::taskWaitMulti

Execute multiple tasks concurrently.

说明

public void Swoole\Server::taskWaitMulti ( array $tasks [, double $timeout_ms ] )

参数

tasks

timeout_ms

返回值

Swoole\Server::tick

Repeats a given function at every given time-interval.

说明

public void Swoole\Server::tick ( integer $interval_ms , callable $callback )

参数

interval_ms

callback

返回值

简介

类摘要

Swoole\Table

class Swoole\Table implements Iterator , Countable {

/* Constants */

const integer Swoole\Table::TYPE_INT = 1 ;

const integer Swoole\Table::TYPE_STRING = 7 ;

const integer Swoole\Table::TYPE_FLOAT = 6 ;

/* 方法 */

public ReturnType column ( string $name , string $type [, integer $size ] )

public integer count ( void )

public void create ( void )

public array current ( void )

public ReturnType decr ( string $key , string $column [, integer $decrby ] )

public void del ( string $key )

public void destroy ( void )

public boolean exist ( string $key )

public integer get ( string $row_key , string $column_key )

public void incr ( string $key , string $column [, integer $incrby ] )

public string key ( void )

public ReturnType next ( void )

public void rewind ( void )

public VOID set ( string $key , array $value )

public boolean valid ( void )

}

预定义常量

Swoole\Table::TYPE_INT

Swoole\Table::TYPE_STRING

Swoole\Table::TYPE_FLOAT

Swoole\Table::column

Set the data type and size of the columns.

说明

public ReturnType Swoole\Table::column ( string $name , string $type [, integer $size ] )

参数

name

type

size

返回值

Swoole\Table::__construct

Construct a Swoole memory table with fixed size.

说明

public Swoole\Table::__construct ( integer $table_size )

参数

table_size

Swoole\Table::count

Count the rows in the table, or count all the elements in the table if $mode = 1.

说明

public integer Swoole\Table::count ( void )

参数

此函数没有参数。

返回值

Swoole\Table::create

Create the swoole memory table.

说明

public void Swoole\Table::create ( void )

参数

此函数没有参数。

返回值

Swoole\Table::current

Get the current row.

说明

public array Swoole\Table::current ( void )

参数

此函数没有参数。

返回值

Swoole\Table::decr

Decrement the value in the Swoole table by $row_key and $column_key.

说明

public ReturnType Swoole\Table::decr ( string $key , string $column [, integer $decrby ] )

参数

key

column

decrby

返回值

Swoole\Table::del

Delete a row in the Swoole table by $row_key.

说明

public void Swoole\Table::del ( string $key )

参数

key

返回值

Swoole\Table::destroy

Destroy the Swoole table.

说明

public void Swoole\Table::destroy ( void )

参数

此函数没有参数。

返回值

Swoole\Table::exist

Check if a row is existed by $row_key.

说明

public boolean Swoole\Table::exist ( string $key )

参数

key

返回值

Swoole\Table::get

Get the value in the Swoole table by $row_key and $column_key.

说明

public integer Swoole\Table::get ( string $row_key , string $column_key )

参数

row_key

column_key

返回值

Swoole\Table::incr

Increment the value by $row_key and $column_key.

说明

public void Swoole\Table::incr ( string $key , string $column [, integer $incrby ] )

参数

key

column

incrby

返回值

Swoole\Table::key

Get the key of current row.

说明

public string Swoole\Table::key ( void )

参数

此函数没有参数。

返回值

Swoole\Table::next

Iterator the next row.

说明

public ReturnType Swoole\Table::next ( void )

参数

此函数没有参数。

返回值

Swoole\Table::rewind

Rewind the iterator.

说明

public void Swoole\Table::rewind ( void )

参数

此函数没有参数。

返回值

Swoole\Table::set

Update a row of the table by $row_key.

说明

public VOID Swoole\Table::set ( string $key , array $value )

参数

key

value

返回值

Swoole\Table::valid

Check current if the current row is valid.

说明

public boolean Swoole\Table::valid ( void )

参数

此函数没有参数。

返回值

简介

类摘要

Swoole\Timer

class Swoole\Timer {

/* 方法 */

public static void after ( int $after_time_ms , callable $callback )

public static void clear ( integer $timer_id )

public static boolean exists ( integer $timer_id )

public static void tick ( integer $interval_ms , callable $callback [, string $param ] )

}

Swoole\Timer::after

Trigger a callback function after a period of time.

说明

public static void Swoole\Timer::after ( int $after_time_ms , callable $callback )

Trigger a callback function after a period of time.

参数

after_time_ms

callback

返回值

Swoole\Timer::clear

Delete a timer by timer ID.

说明

public static void Swoole\Timer::clear ( integer $timer_id )

Delete a timer by timer ID.

参数

timer_id

返回值

Swoole\Timer::exists

Check if a timer is existed.

说明

public static boolean Swoole\Timer::exists ( integer $timer_id )

Check if a timer is existed.

参数

timer_id

返回值

Swoole\Timer::tick

Repeats a given function at every given time-interval.

说明

public static void Swoole\Timer::tick ( integer $interval_ms , callable $callback [, string $param ] )

参数

interval_ms

callback

param

返回值

简介

类摘要

Swoole\WebSocket\Frame

class Swoole\WebSocket\Frame {

/* 方法 */

}

简介

类摘要

Swoole\WebSocket\Server

class Swoole\WebSocket\Server extends Swoole\Http\Server {

/* 方法 */

public boolean exist ( integer $fd )

public ReturnType on ( string $event_name , callable $callback )

public static binary pack ( string $data [, string $opcode [, string $finish [, string $mask ]]] )

public void push ( string $fd , string $data [, string $opcode [, string $finish ]] )

public static string unpack ( binary $data )

/* 继承的方法 */

public void Swoole\Http\Server::on ( string $event_name , callable $callback )

public void Swoole\Http\Server::start ( void )

}

Swoole\WebSocket\Server::exist

Check if the file descriptor exists.

说明

public boolean Swoole\WebSocket\Server::exist ( integer $fd )

参数

fd

返回值

Swoole\WebSocket\Server::on

Register event callback function

说明

public ReturnType Swoole\WebSocket\Server::on ( string $event_name , callable $callback )

Register event callback function

参数

event_name

callback

返回值

Swoole\WebSocket\Server::pack

Get a pack of binary data to send in a single frame.

说明

public static binary Swoole\WebSocket\Server::pack ( string $data [, string $opcode [, string $finish [, string $mask ]]] )

参数

data

opcode

finish

mask

返回值

Swoole\WebSocket\Server::push

Push data to the remote client.

说明

public void Swoole\WebSocket\Server::push ( string $fd , string $data [, string $opcode [, string $finish ]] )

参数

fd

data

opcode

finish

返回值

Swoole\WebSocket\Server::unpack

Unpack the binary data received from the client.

说明

public static string Swoole\WebSocket\Server::unpack ( binary $data )

参数

data

返回值