This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.5) | |
project(extname | |
VERSION 1.0.0 | |
LANGUAGES C) | |
message(STATUS "Begin cmaking of PHP extension ...") | |
if (NOT CMAKE_BUILD_TYPE) | |
set(CMAKE_BUILD_TYPE Debug CACHE STRING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ZMTP/2.0 http://rfc.zeromq.org/spec:15 | |
// ZMTP/1.0 http://rfc.zeromq.org/spec:13 | |
$fp = fsockopen("127.0.0.1", 5559, $errno, $errstr, 1); | |
if (!$fp) { | |
return; | |
} | |
stream_set_timeout($fp, 0, 500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (c) 2020 Chan Jer Shyan | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once "zmtp.php"; | |
// This was connecting to a libzmq master based subscriber. | |
$host = "127.0.0.1"; | |
$port = 4422; | |
// Connect and send null mechanism. | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
$rc = socket_connect($socket, $host, $port); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go encourages us to organize our code using goroutines and to use | |
// channels of channels to implement request-response semantics [1]. | |
// | |
// I have encountered far more instances that require acknowledgment | |
// than fully-fledged respones so I became curious whether channels | |
// of channels were indeed the best implementation strategy. | |
// | |
// In summary, yes, they are. These benchmarks demonstrate that | |
// channels perform better than mutexes, that condition variables are | |
// still clumsy, and that preallocation is a huge win when and if you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
// ... | |
protected function spawnProcess() | |
{ | |
if (!function_exists('proc_open')) { | |
throw new \RuntimeException( |