PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

ZMQContext::getSocket - Create a new socket | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

ZMQContext::getSocket

(PECL zmq >= 0.5.0)

ZMQContext::getSocketCreate a new socket

説明

public ZMQSocket ZMQContext::getSocket ( integer $type [, string $persistent_id = null [, callback $on_new_socket = null ]] )

Shortcut for creating new sockets from the context. If the context is not persistent the persistent_id parameter is ignored and the socket falls back to being non-persistent. The on_new_socket is called only when a new underlying socket structure is created.

パラメータ

type

ZMQ::SOCKET_* constant to specify socket type.

persistent_id

If persistent_id is specified the socket will be persisted over multiple requests.

on_new_socket

Callback function, which is executed when a new socket structure is created. This function does not get invoked if the underlying persistent connection is re-used. The callback takes ZMQSocket and persistent_id as two arguments.

例1 A ZMQContext() example

Basic usage

<?php
/* Allocate a new context */
$context = new ZMQContext();

/* Create a new socket */
$socket $context->getSocket(ZMQ::SOCKET_REQ'my sock');

/* Connect the socket */
$socket->connect("tcp://example.com:1234");

/* Send a request */
$socket->send("Hello there");

/* Receive back the response */
$message $socket->recv();
echo 
"Received message: {$message}\n";
?>

返り値

Returns a ZMQSocket object on success. Throws ZMQSocketException on error.


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「ZMQContext::getSocket - Create a new socket」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | ZMQContext::getSocket - Create a new socket」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: