Swoole

Swoole

PHP는 웹 요청을 처리하는 서버 개발에는 강하지만, 실시간 통신이나 고성능 네트워크 서버를 만드는 데는 제약이 있다는 평가를 받아요. Swoole은 C++로 작성된 비동기 이벤트 기반·코루틴 기반의 병렬 네트워크 통신 엔진으로, PHP에 코루틴과 고성능 네트워크 프로그래밍 지원을 더해 이런 한계를 넘어서려는 확장이에요.

출처: Swoole

본문

Swoole은 **비동기 이벤트 기반(asynchronous event-driven)과 코루틴(coroutine)**을 바탕으로 한 병렬 네트워크 통신 엔진이에요. C++로 작성됐으며, PHP에 코루틴과 고성능 네트워크 프로그래밍 지원을 제공해요.

다양한 통신 프로토콜을 위한 여러 네트워크 서버·클라이언트 모듈을 제공해서, TCP/UDP 서비스, 고성능 Web, WebSocket 서비스, IoT, 실시간 통신, 게임, 마이크로서비스 등을 빠르게 구현할 수 있어요. 전통적인 웹 영역에서의 PHP 한계를 깨는 데 초점이 맞춰져 있어요.

시작하려면 » Swoole Docs를 확인하세요.

참고(Note): 이 확장은 Windows 플랫폼에서는 사용할 수 없어요.

설치·설정(Installing/Configuring)

  • 요구 사항(Requirements)
  • 설치(Installation)
  • 런타임 설정(Runtime Configuration)
  • 사전 정의 상수(Predefined Constants)

Swoole 함수(Swoole Functions)

  • swoole_async_dns_lookup — 비동기·논블로킹 호스트명→IP 조회(Async and non-blocking hostname to IP lookup).
  • swoole_async_read — 파일 스트림을 비동기로 읽어요(Read file stream asynchronously).
  • swoole_async_readfile — 파일을 비동기로 읽어요(Read a file asynchronously).
  • swoole_async_set — 비동기 I/O 옵션을 갱신해요(Update the async I/O options).
  • swoole_async_write — 파일 스트림에 비동기로 데이터를 써요(Write data to a file stream asynchronously).
  • swoole_async_writefile — 파일에 비동기로 데이터를 써요(Write data to a file asynchronously).
  • swoole_clear_error — 소켓 또는 마지막 오류 코드의 오류를 지워요(Clear errors in the socket or on the last error code).
  • swoole_client_select — 읽기/쓰기 또는 오류에 준비된 파일 설명자를 가져와요(Get the file description which are ready to read/write or error).
  • swoole_cpu_num — CPU 개수를 가져와요(Get the number of CPU).
  • swoole_errno — 최신 시스템 호출의 오류 코드를 가져와요(Get the error code of the latest system call).
  • swoole_error_log — 로그에 오류 메시지를 출력해요(Output error messages to the log).
  • swoole_event_add — 소켓의 새 콜백 함수를 EventLoop에 추가해요(Add new callback functions of a socket into the EventLoop).
  • swoole_event_defer — 다음 이벤트 루프에 콜백 함수를 추가해요(Add callback function to the next event loop).
  • swoole_event_del — 소켓의 모든 이벤트 콜백 함수를 제거해요(Remove all event callback functions of a socket).
  • swoole_event_exit — 이벤트 루프를 종료해요(클라이언트 쪽에서만 사용 가능)(Exit the eventloop, only available at the client side).
  • swoole_event_set — 소켓의 이벤트 콜백 함수를 갱신해요(Update the event callback functions of a socket).
  • swoole_event_wait — 이벤트 루프를 시작해요(Start the event loop).
  • swoole_event_write — 소켓에 데이터를 써요(Write data to a socket).
  • swoole_get_local_ip — 머신의 각 NIC IPv4 IP 주소를 가져와요(Get the IPv4 IP addresses of each NIC on the machine).
  • swoole_last_error — 최신 오류 메시지를 가져와요(Get the latest error message).
  • swoole_load_module — swoole 확장을 로드해요(Load a swoole extension).
  • swoole_select — 이벤트 루프에서 읽기/쓰기 또는 오류에 준비된 파일 설명자를 선택해요(Select the file descriptions which are ready to read/write or error in the eventloop).
  • swoole_set_process_name — 프로세스 이름을 설정해요(Set the process name).
  • swoole_strerror — Errno를 오류 메시지로 변환해요(Convert the Errno into error messages).
  • swoole_timer_after — 미래의 어느 시점에 일회성 콜백 함수를 실행해요(Trigger a one time callback function in the future).
  • swoole_timer_exists — 타이머 콜백 함수가 존재하는지 확인해요(Check if a timer callback function is existed).
  • swoole_timer_tick — 시간 간격으로 타이머 틱 콜백 함수를 실행해요(Trigger a timer tick callback function by time interval).
  • swoole_version — Swoole 버전을 가져와요(Get the version of Swoole).

Swoole\Async 클래스

  • Swoole\Async — Swoole\Async 클래스
  • Swoole\Async::dnsLookup — 비동기·논블로킹 호스트명→IP 조회(Async and non-blocking hostname to IP lookup).
  • Swoole\Async::read — 파일 스트림을 비동기로 읽어요(Read file stream asynchronously).
  • Swoole\Async::readFile — 파일을 비동기로 읽어요(Read a file asynchronously).
  • Swoole\Async::set — 비동기 I/O 옵션을 갱신해요(Update the async I/O options).
  • Swoole\Async::write — 파일 스트림에 비동기로 데이터를 써요(Write data to a file stream asynchronously).
  • Swoole\Async::writeFile — 설명(Description).

Swoole\Atomic 클래스

  • Swoole\Atomic — Swoole\Atomic 클래스
  • Swoole\Atomic::add — 원자 객체의 값에 숫자를 더해요(Add a number to the value to the atomic object).
  • Swoole\Atomic::cmpset — 원자 객체의 값을 비교하고 설정해요(Compare and set the value of the atomic object).
  • Swoole\Atomic::__construct — swoole 원자 객체를 생성해요(Construct a swoole atomic object).
  • Swoole\Atomic::get — 원자 객체의 현재 값을 가져와요(Get the current value of the atomic object).
  • Swoole\Atomic::set — 원자 객체에 새 값을 설정해요(Set a new value to the atomic object).
  • Swoole\Atomic::sub — 원자 객체의 값에서 숫자를 빼요(Subtract a number to the value of the atomic object).

Swoole\Buffer 클래스

  • Swoole\Buffer — Swoole\Buffer 클래스
  • Swoole\Buffer::append — 메모리 버퍼 끝에 문자열 또는 바이너리 데이터를 추가하고 새 할당 크기를 반환해요(Append the string or binary data at the end of the memory buffer and return the new size of memory allocated).
  • Swoole\Buffer::clear — 메모리 버퍼를 초기화해요(Reset the memory buffer).
  • Swoole\Buffer::__construct — 고정 크기 메모리 블록 할당(Fixed size memory blocks allocation).
  • Swoole\Buffer::__destruct — Swoole 메모리 버퍼를 소멸해요(Destruct the Swoole memory buffer).
  • Swoole\Buffer::expand — 메모리 버퍼 크기를 확장해요(Expand the size of memory buffer).
  • Swoole\Buffer::read — 오프셋과 길이 기준으로 메모리 버퍼에서 데이터를 읽어요(Read data from the memory buffer based on offset and length).
  • Swoole\Buffer::recycle — 메모리 버퍼가 쓰지 않는 메모리를 OS에 되돌려줘요(Release the memory to OS which is not used by the memory buffer).
  • Swoole\Buffer::substr — 오프셋과 길이 기준으로 메모리 버퍼에서 데이터를 읽거나, 버퍼에서 데이터를 제거해요(Read data from the memory buffer based on offset and length. Or remove data from the memory buffer).
  • Swoole\Buffer::__toString — 메모리 버퍼의 문자열 값을 가져와요(Get 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).

Swoole\Channel 클래스

  • Swoole\Channel — Swoole\Channel 클래스
  • Swoole\Channel::__construct — Swoole Channel을 생성해요(Construct a Swoole Channel).
  • Swoole\Channel::__destruct — Swoole channel을 소멸해요(Destruct a Swoole channel).
  • Swoole\Channel::pop — swoole channel에서 데이터를 읽고 꺼내요(Read and pop data from swoole channel).
  • Swoole\Channel::push — swoole channel에 데이터를 쓰고 넣어요(Write and push data into Swoole channel).
  • Swoole\Channel::stats — swoole channel 통계를 가져와요(Get stats of swoole channel).

Swoole\Client 클래스

  • Swoole\Client — Swoole\Client 클래스
  • Swoole\Client::close — 만들어진 연결을 닫아요(Close the connection established).
  • Swoole\Client::connect — 원격 TCP 또는 UDP 포트에 연결해요(Connect to the remote TCP or UDP port).
  • Swoole\Client::__construct — SSL 유무와 상관없이 Swoole 동기 또는 비동기 TCP/UDP 클라이언트를 만들어요(Create Swoole sync or async TCP/UDP client, with or without SSL).
  • Swoole\Client::__destruct — Swoole 클라이언트를 소멸해요(Destruct the Swoole client).
  • Swoole\Client::getpeername — 연결의 원격 소켓 이름을 가져와요(Get the remote socket name of the connection).
  • Swoole\Client::getsockname — 연결의 로컬 소켓 이름을 가져와요(Get the local socket name of the connection).
  • Swoole\Client::isConnected — 연결이 성립됐는지 확인해요(Check if the connection is established).
  • Swoole\Client::on — 이벤트로 촉발되는 콜백 함수를 추가해요(Add callback functions triggered by events).
  • Swoole\Client::pause — 데이터 수신을 일시 중지해요(Pause receiving data).
  • Swoole\Client::pipe — 데이터를 다른 파일 설명자로 리다이렉트해요(Redirect the data to another file descriptor).
  • Swoole\Client::recv — 원격 소켓에서 데이터를 받아요(Receive data from the remote socket).
  • Swoole\Client::resume — 데이터 수신을 재개해요(Resume receiving data).
  • Swoole\Client::send — 원격 TCP 소켓에 데이터를 보내요(Send data to the remote TCP socket).
  • Swoole\Client::sendfile — 원격 TCP 소켓에 파일을 보내요(Send file to the remote TCP socket).
  • Swoole\Client::sendto — 원격 UDP 주소에 데이터를 보내요(Send data to the remote UDP address).
  • Swoole\Client::set — 연결이 성립되기 전에 Swoole 클라이언트 매개변수를 설정해요(Set the Swoole client parameters before the connection is established).
  • Swoole\Client::sleep — 시스템 이벤트 루프에서 TCP 클라이언트를 제거해요(Remove the TCP client from system event loop).
  • Swoole\Client::wakeup — TCP 클라이언트를 시스템 이벤트 루프에 다시 추가해요(Add the TCP client back into the system event loop).

Swoole\Connection\Iterator 클래스

  • Swoole\Connection\Iterator — Swoole\Connection\Iterator 클래스
  • Swoole\Connection\Iterator::count — 연결 수를 세요(Count connections).
  • Swoole\Connection\Iterator::current — 현재 연결 항목을 반환해요(Return current connection entry).
  • Swoole\Connection\Iterator::key — 현재 연결의 키를 반환해요(Return key of the current connection).
  • Swoole\Connection\Iterator::next — 다음 연결로 이동해요(Move to the next connection).
  • Swoole\Connection\Iterator::offsetExists — 오프셋이 존재하는지 확인해요(Check if offset exists).
  • Swoole\Connection\Iterator::offsetGet — 가져올 오프셋(Offset to retrieve).
  • Swoole\Connection\Iterator::offsetSet — 지정한 오프셋에 Connection을 할당해요(Assign a Connection to the specified offset).
  • Swoole\Connection\Iterator::offsetUnset — 오프셋을 해제해요(Unset an offset).
  • Swoole\Connection\Iterator::rewind — 반복자를 되감아요(Rewinds iterator).
  • Swoole\Connection\Iterator::valid — 현재 위치가 유효한지 확인해요(Check if current position is valid).

Swoole\Coroutine 클래스

  • Swoole\Coroutine — Swoole\Coroutine 클래스
  • Swoole\Coroutine::call_user_func — 첫 번째 매개변수가 주는 콜백을 호출해요(Call a callback given by the first parameter).
  • Swoole\Coroutine::call_user_func_array — 매개변수 배열로 콜백을 호출해요(Call a callback with an array of parameters).
  • Swoole\Coroutine::cli_wait — 설명(Description).
  • Swoole\Coroutine::create — 설명(Description).
  • Swoole\Coroutine::getuid — 설명(Description).
  • Swoole\Coroutine::resume — 설명(Description).
  • Swoole\Coroutine::suspend — 설명(Description).
  • Swoole\Coroutine\Lock — Swoole\Coroutine\Lock 클래스
  • Swoole\Coroutine\Lock::__construct — 새 코루틴 잠금을 생성해요(Construct a new coroutine lock).
  • Swoole\Coroutine\Lock::lock — 필요한 경우 블로킹하며 잠금을 획득해요(Acquire the lock, blocking if necessary).
  • Swoole\Coroutine\Lock::trylock — 블로킹 없이 잠금 획득을 시도해요(Attempt to acquire the lock without blocking).
  • Swoole\Coroutine\Lock::unlock — 잠금을 해제해요(Release the lock).

Swoole\Event 클래스

  • Swoole\Event — Swoole\Event 클래스
  • Swoole\Event::add — 리액터 이벤트 리스너에 소켓을 추가해요(Add a socket to the underlying reactor event listener).
  • Swoole\Event::cycle — 각 이벤트 루프 반복 끝에 실행할 함수를 정의해요(Define a function to execute at the end of each event loop iteration).
  • Swoole\Event::defer — 다음 이벤트 루프 시작에 함수를 실행해요(Execute a function at the start of the next event loop).
  • Swoole\Event::del — 리액터 이벤트 리스너에서 소켓을 제거해요(Remove a socket from reactor event listener).
  • Swoole\Event::dispatch — 단일 이벤트 루프 반복을 수행해요(Perform a single event loop iteration).
  • Swoole\Event::isset — 소켓이 이벤트 루프에서 모니터링되고 있는지 확인해요(Check if a socket is being monitored in the event loop).
  • Swoole\Event::set — 이벤트 리스너 콜백과 마스크를 수정해요(Modify event listener callbacks and mask).
  • Swoole\Event::wait — 이벤트 루프를 시작해요(Start event loop).
  • Swoole\Event::write — 소켓에 비동기로 데이터를 써요(Write data to socket asynchronously).
  • Swoole\Exception — Swoole\Exception 클래스

Swoole\Http\Client 클래스

  • Swoole\Http\Client — Swoole\Http\Client 클래스
  • Swoole\Http\Client::addFile — post 폼에 파일을 추가해요(Add a file to the post form).
  • Swoole\Http\Client::close — http 연결을 닫아요(Close the http connection).
  • Swoole\Http\Client::__construct — 비동기 HTTP 클라이언트를 생성해요(Construct the async HTTP client).
  • Swoole\Http\Client::__destruct — HTTP 클라이언트를 소멸해요(Destruct the HTTP client).
  • Swoole\Http\Client::download — 원격 서버에서 파일을 다운로드해요(Download a file from the remote server).
  • Swoole\Http\Client::execute — 매개변수 설정 후 HTTP 요청을 보내요(Send the HTTP request after setting the parameters).
  • Swoole\Http\Client::get — 원격 서버에 GET http 요청을 보내요(Send GET http request to the remote server).
  • Swoole\Http\Client::isConnected — HTTP 연결이 연결됐는지 확인해요(Check if the HTTP connection is connected).
  • Swoole\Http\Client::on — 이벤트 이름으로 콜백 함수를 등록해요(Register callback function by event name).
  • Swoole\Http\Client::post — 원격 서버에 POST http 요청을 보내요(Send POST http request to the remote server).
  • Swoole\Http\Client::push — websocket 클라이언트에 데이터를 밀어 넣어요(Push data to websocket client).
  • Swoole\Http\Client::set — HTTP 클라이언트 매개변수를 갱신해요(Update the HTTP client parameters).
  • Swoole\Http\Client::setCookies — http 요청 쿠키를 설정해요(Set the http request cookies).
  • Swoole\Http\Client::setData — HTTP 요청 본문 데이터를 설정해요(Set the HTTP request body data).
  • Swoole\Http\Client::setHeaders — HTTP 요청 헤더를 설정해요(Set the HTTP request headers).
  • Swoole\Http\Client::setMethod — HTTP 요청 메서드를 설정해요(Set the HTTP request method).
  • Swoole\Http\Client::upgrade — websocket 프로토콜로 업그레이드해요(Upgrade to websocket protocol).

Swoole\Http\Request 클래스

  • Swoole\Http\Request — Swoole\Http\Request 클래스
  • Swoole\Http\Request::__destruct — HTTP 요청을 소멸해요(Destruct the HTTP request).
  • Swoole\Http\Request::rawcontent — 원시 HTTP POST 본문을 가져와요(Get the raw HTTP POST body).

Swoole\Http\Response 클래스

  • Swoole\Http\Response — Swoole\Http\Response 클래스
  • Swoole\Http\Response::cookie — HTTP 응답의 쿠키를 설정해요(Set the cookies of the HTTP response).
  • Swoole\Http\Response::__destruct — HTTP 응답을 소멸해요(Destruct the HTTP response).
  • Swoole\Http\Response::end — HTTP 요청에 데이터를 보내고 응답을 끝내요(Send data for the HTTP request and finish the response).
  • Swoole\Http\Response::gzip — 응답 콘텐츠의 gzip을 활성화해요(Enable the gzip of response content).
  • Swoole\Http\Response::header — HTTP 응답 헤더를 설정해요(Set the HTTP response headers).
  • Swoole\Http\Response::initHeader — HTTP 응답 헤더를 초기화해요(Init the HTTP response header).
  • Swoole\Http\Response::rawcookie — HTTP 응답에 raw 쿠키를 설정해요(Set the raw cookies to the HTTP response).
  • Swoole\Http\Response::sendfile — HTTP 응답을 통해 파일을 보내요(Send file through the HTTP response).
  • Swoole\Http\Response::status — HTTP 응답의 상태 코드를 설정해요(Set the status code of the HTTP response).
  • Swoole\Http\Response::write — HTTP 응답에 HTTP 본문 콘텐츠를 추가해요(Append HTTP body content to the HTTP response).

Swoole\Http\Server 클래스

  • Swoole\Http\Server — Swoole\Http\Server 클래스
  • Swoole\Http\Server::on — 이벤트 이름으로 HTTP 서버에 콜백 함수를 바인딩해요(Bind callback function to HTTP server by event name).
  • Swoole\Http\Server::start — swoole http 서버를 시작해요(Start the swoole http server).

Swoole\Lock 클래스

  • Swoole\Lock — Swoole\Lock 클래스
  • Swoole\Lock::__construct — 메모리 잠금을 생성해요(Construct a memory lock).
  • Swoole\Lock::__destruct — Swoole 메모리 잠금을 파괴해요(Destroy a Swoole memory lock).
  • Swoole\Lock::lock — 잠금 획득을 시도해요(사용 불가하면 블로킹)(Try to acquire the lock. It will block if the lock is not available).
  • Swoole\Lock::lock_read — 읽기-쓰기 잠금을 읽기 위해 잠가요(Lock a read-write lock for reading).
  • Swoole\Lock::trylock — 잠금 획득을 시도하고 사용 불가해도 바로 반환해요(Try to acquire the lock and return straight away even the lock is not available).
  • Swoole\Lock::trylock_read — 읽기-쓰기 잠금을 읽기 위해 잠그려 시도하고 사용 불가해도 바로 반환해요(Try to lock a read-write lock for reading and return straight away even the lock is not available).
  • Swoole\Lock::unlock — 잠금을 해제해요(Release the lock).

Swoole\Mmap 클래스

  • Swoole\Mmap — Swoole\Mmap 클래스
  • Swoole\Mmap::open — 파일을 메모리에 매핑하고 PHP 스트림 연산으로 쓸 수 있는 스트림 리소스를 반환해요(Map a file into memory and return the stream resource which can be used by PHP stream operations).

Swoole\Module 클래스

  • Swoole\Module — Swoole\Module 클래스

Swoole\MySQL 클래스

  • Swoole\MySQL — Swoole\MySQL 클래스
  • Swoole\MySQL::close — 비동기 MySQL 연결을 닫아요(Close the async MySQL connection).
  • Swoole\MySQL::connect — 원격 MySQL 서버에 연결해요(Connect to the remote MySQL server).
  • Swoole\MySQL::__construct — 비동기 MySQL 클라이언트를 생성해요(Construct an async MySQL client).
  • Swoole\MySQL::__destruct — 비동기 MySQL 클라이언트를 파괴해요(Destroy the async MySQL client).
  • Swoole\MySQL::getBuffer — 설명(Description).
  • Swoole\MySQL::on — 이벤트 이름 기반으로 콜백 함수를 등록해요(Register callback function based on event name).
  • Swoole\MySQL::query — SQL 쿼리를 실행해요(Run the SQL query).
  • Swoole\MySQL\Exception — Swoole\MySQL\Exception 클래스

Swoole\Process 클래스

  • Swoole\Process — Swoole\Process 클래스
  • Swoole\Process::alarm — 고정 간격으로 신호를 촉발하는 고정밀 타이머(High precision timer which triggers signal with fixed interval).
  • Swoole\Process::close — 자식 프로세스로 가는 파이프를 닫아요(Close the pipe to the child process).
  • Swoole\Process::__construct — 프로세스를 생성해요(Construct a process).
  • Swoole\Process::daemon — 프로세스를 데몬 프로세스로 변경해요(Change the process to be a daemon process).
  • Swoole\Process::__destruct — 프로세스를 파괴해요(Destroy the process).
  • Swoole\Process::exec — 시스템 명령을 실행해요(Execute system commands).
  • Swoole\Process::exit — 자식 프로세스를 중지해요(Stop the child processes).
  • Swoole\Process::freeQueue — swoole_process::useQueue가 만든 메시지 큐를 파괴해요(Destroy the message queue created by swoole_process::useQueue).
  • Swoole\Process::kill — 자식 프로세스에 신호를 보내요(Send signal to the child process).
  • Swoole\Process::name — 프로세스 이름을 설정해요(Set name of the process).
  • Swoole\Process::pop — 메시지 큐에서 데이터를 읽고 꺼내요(Read and pop data from the message queue).
  • Swoole\Process::push — 메시지 큐에 데이터를 쓰고 넣어요(Write and push data into the message queue).
  • Swoole\Process::read — 프로세스로 보내지는 데이터를 읽어요(Read data sending to the process).
  • Swoole\Process::signal — 자식 프로세스에 신호를 보내요(Send signal to the child processes).
  • Swoole\Process::start — 프로세스를 시작해요(Start the process).
  • Swoole\Process::statQueue — 프로세스 간 통신 방법으로 쓰이는 메시지 큐의 통계를 가져와요(Get the stats of the message queue used as the communication method between processes).
  • Swoole\Process::useQueue — 부모·자식 프로세스 간 통신 방법으로 메시지 큐를 만들어요(Create a message queue as the communication method between the parent process and child processes).
  • Swoole\Process::wait — 자식 프로세스의 이벤트를 기다려요(Wait for the events of child processes).
  • Swoole\Process::write — 파이프에 데이터를 쓰고 부모 또는 자식 프로세스와 통신해요(Write data into the pipe and communicate with the parent process or child processes).

Swoole\Redis\Server 클래스

  • Swoole\Redis\Server — Swoole\Redis\Server 클래스
  • Swoole\Redis\Server::format — 설명(Description).
  • Swoole\Redis\Server::setHandler — 설명(Description).
  • Swoole\Redis\Server::start — 설명(Description).

Swoole\Runtime 클래스

  • Swoole\Runtime — Swoole\Runtime 클래스
  • Swoole\Runtime::enableCoroutine — 지정한 함수에 코루틴을 활성화해요(Enable coroutine for specified functions).
  • Swoole\Runtime::getHookFlags — 현재 훅 플래그를 가져와요(Get current hook flags).
  • Swoole\Runtime::setHookFlags — 코루틴용 훅 플래그를 설정해요(Set hook flags for coroutine).

Swoole\Serialize 클래스

  • Swoole\Serialize — Swoole\Serialize 클래스
  • Swoole\Serialize::pack — 데이터를 직렬화해요(Serialize the data).
  • Swoole\Serialize::unpack — 데이터를 역직렬화해요(Unserialize the data).

Swoole\Server 클래스

  • Swoole\Server — Swoole\Server 클래스
  • Swoole\Server::addlistener — 서버에 새 리스너를 추가해요(Add a new listener to the server).
  • Swoole\Server::addProcess — 서버에 사용자 정의 swoole_process를 추가해요(Add a user defined swoole_process to the server).
  • Swoole\Server::after — 일정 시간 후 콜백 함수를 실행해요(Trigger a callback function after a period of time).
  • Swoole\Server::bind — 연결을 사용자 정의 사용자 ID에 바인딩해요(Bind the connection to a user defined user ID).
  • Swoole\Server::clearTimer — 타이머를 중지하고 파괴해요(Stop and destroy a timer).
  • Swoole\Server::close — 클라이언트와의 연결을 닫아요(Close a connection to the client).
  • Swoole\Server::confirm — 연결 상태를 확인해요(Check status of the connection).
  • Swoole\Server::connection_info — 파일 설명자로 연결 정보를 가져와요(Get the connection info by file description).
  • Swoole\Server::connection_list — 성립된 모든 연결을 가져와요(Get all of the established connections).
  • Swoole\Server::__construct — Swoole 서버를 생성해요(Construct a Swoole server).
  • Swoole\Server::defer — 현재 EventLoop 끝에서 콜백 함수 실행을 지연해요(Delay execution of the callback function at the end of current EventLoop).
  • Swoole\Server::exist — 연결이 존재하는지 확인해요(Check if the connection is existed).
  • Swoole\Server::finish — task가 끝났을 때 task 프로세스에서 worker 프로세스로 결과를 보내는 데 써요(Used in task process for sending result to the worker process when the task is finished).
  • Swoole\Server::getClientInfo — 파일 설명자로 연결 정보를 가져와요(Get the connection info by file description).
  • Swoole\Server::getClientList — 성립된 모든 연결을 가져와요(Get all of the established connections).
  • Swoole\Server::getLastError — 가장 최근 오류의 오류 코드를 가져와요(Get the error code of the most recent error).
  • Swoole\Server::heartbeat — 서버의 모든 연결을 검사해요(Check all the connections on the server).
  • Swoole\Server::listen — 주어진 IP·포트·소켓 타입에서 수신해요(Listen on the given IP and port, socket type).
  • Swoole\Server::on — 이벤트 이름으로 콜백 함수를 등록해요(Register a callback function by event name).
  • Swoole\Server::pause — 연결에서 데이터 수신을 중지해요(Stop receiving data from the connection).
  • Swoole\Server::protect — 연결을 보호 모드로 설정해요(Set the connection to be protected mode).
  • Swoole\Server::reload — 모든 worker 프로세스를 다시 시작해요(Restart all the worker process).
  • Swoole\Server::resume — 연결에서 데이터 수신을 시작해요(Start receiving data from the connection).
  • Swoole\Server::send — 클라이언트에 데이터를 보내요(Send data to the client).
  • Swoole\Server::sendfile — 연결에 파일을 보내요(Send file to the connection).
  • Swoole\Server::sendMessage — ID로 worker 프로세스에 메시지를 보내요(Send message to worker processes by ID).
  • Swoole\Server::sendto — 원격 UDP 주소에 데이터를 보내요(Send data to the remote UDP address).
  • Swoole\Server::sendwait — 블로킹 방식으로 원격 소켓에 데이터를 보내요(Send data to the remote socket in the blocking way).
  • Swoole\Server::set — swoole 서버의 런타임 설정을 설정해요(Set the runtime settings of the swoole server).
  • Swoole\Server::shutdown — 마스터 서버 프로세스를 종료해요(worker 프로세스에서 호출 가능)(Shutdown the master server process, this function can be called in worker processes).
  • Swoole\Server::start — Swoole 서버를 시작해요(Start the Swoole server).
  • Swoole\Server::stats — Swoole 서버의 통계를 가져와요(Get the stats of the Swoole server).
  • Swoole\Server::stop — Swoole 서버를 중지해요(Stop the Swoole server).
  • Swoole\Server::task — task worker 프로세스에 데이터를 보내요(Send data to the task worker processes).
  • Swoole\Server::taskwait — 블로킹 방식으로 task worker 프로세스에 데이터를 보내요(Send data to the task worker processes in blocking way).
  • Swoole\Server::taskWaitMulti — 여러 작업을 동시에 실행해요(Execute multiple tasks concurrently).
  • Swoole\Server::tick — 주어진 시간 간격마다 주어진 함수를 반복해요(Repeats a given function at every given time-interval).

Swoole\Table 클래스

  • Swoole\Table — Swoole\Table 클래스
  • Swoole\Table::column — 열의 데이터 타입과 크기를 설정해요(Set the data type and size of the columns).
  • Swoole\Table::__construct — 고정 크기의 Swoole 메모리 테이블을 생성해요(Construct a Swoole memory table with fixed size).
  • Swoole\Table::count — 테이블의 행 수를 세거나, $mode = 1이면 테이블의 모든 요소를 세요(Count the rows in the table, or count all the elements in the table if $mode = 1).
  • Swoole\Table::create — swoole 메모리 테이블을 만들어요(Create the swoole memory table).
  • Swoole\Table::current — 현재 행을 가져와요(Get the current row).
  • Swoole\Table::decr — $key와 $column으로 Swoole 테이블의 값을 감소시켜요(Decrement the value in the Swoole table by $key and $column).
  • Swoole\Table::del — $key로 Swoole 테이블의 행을 삭제해요(Delete a row in the Swoole table by $key).
  • Swoole\Table::destroy — Swoole 테이블을 파괴해요(Destroy the Swoole table).
  • Swoole\Table::exist — $row_key로 행이 존재하는지 확인해요(Check if a row is existed by $row_key).
  • Swoole\Table::get — $key와 $field로 Swoole 테이블의 값을 가져와요(Get the value in the Swoole table by $key and $field).
  • Swoole\Table::incr — $key와 $column으로 값을 증가시켜요(Increment the value by $key and $column).
  • Swoole\Table::key — 현재 행의 키를 가져와요(Get the key of current row).
  • Swoole\Table::next — 반복자를 다음 행으로 이동해요(Advance the iterator to the next row).
  • Swoole\Table::rewind — 반복자를 되감아요(Rewind the iterator).
  • Swoole\Table::set — $key로 테이블의 행을 갱신해요(Update a row of the table by $key).
  • Swoole\Table::valid — 현재 행이 유효한지 확인해요(Check if the current row is valid).

Swoole\Timer 클래스

  • Swoole\Timer — Swoole\Timer 클래스
  • Swoole\Timer::after — 지정 시간 후 함수를 실행해요(Execute a function after a specified time).
  • Swoole\Timer::clear — ID로 타이머를 삭제해요(Delete a timer by ID).
  • Swoole\Timer::clearAll — 현재 프로세스의 모든 타이머를 지워요(Clear all timers in the current process).
  • Swoole\Timer::exists — 타이머가 존재하는지 확인해요(Check if a timer is existed).
  • Swoole\Timer::info — 타이머에 대한 정보를 가져와요(Get information about a timer).
  • Swoole\Timer::list — 현재 프로세스의 타이머에 대한 반복자를 가져와요(Get an iterator over the timers of the current process).
  • Swoole\Timer::set — 타이머 관련 매개변수를 설정해요(Set timer-related parameters).
  • Swoole\Timer::stats — 타이머 통계를 가져와요(Get timer statistics).
  • Swoole\Timer::tick — 반복 간격 타이머를 설정해요(Set a repeating interval timer).

Swoole\WebSocket 클래스

  • Swoole\WebSocket\Frame — Swoole\WebSocket\Frame 클래스
  • Swoole\WebSocket\Server — Swoole\WebSocket\Server 클래스
  • Swoole\WebSocket\Server::exist — 파일 설명자가 존재하는지 확인해요(Check if the file descriptor exists).
  • Swoole\WebSocket\Server::on — 이벤트 콜백 함수를 등록해요(Register event callback function).
  • Swoole\WebSocket\Server::pack — 단일 프레임으로 보낼 바이너리 데이터 묶음을 가져와요(Get a pack of binary data to send in a single frame).
  • Swoole\WebSocket\Server::push — 원격 클라이언트에 데이터를 밀어 넣어요(Push data to the remote client).
  • Swoole\WebSocket\Server::unpack — 클라이언트에서 받은 바이너리 데이터를 풀어요(Unpack the binary data received from the client).

더 알아보기

  • Swoole 공식 문서(Swoole Docs)에서 코루틴과 비동기 모델의 기본을 먼저 잡는 것이 좋아요.
  • 이 확장은 Windows를 지원하지 않으므로, 실제 사용은 Linux 계열 환경에서 해요.
  • Swoole\Server·Coroutine·Event 클래스의 관계를 이해하면 이벤트 기반 프로그래밍 흐름이 훨씬 명확해져요.