PHP Log always view gadgets

Source: Internet
Author: User

Before log is printed in a document, then open the folder, and finally open the document to see what is inside, every time to open the folder feeling very annoying.

Some days ago I saw colleagues develop. NET, it is very convenient to use one of his own gadgets to view the contents of the log at all times, so I want to migrate to PHP development.

First, view the effect

1, open the client gadget Mylog.exe, enter localhost in the address, port input 5555, click the Start link, the next screen will display the word "start listening".

2, open the log.php page, the page is very simple, printed a string of characters.

3, view Mylog.exe, inside has received the Hello string

Second, PHP code

1) to download a PHP version of the Zmq.dll file first

1. Open the link http://pecl.php.net/package/zmq and click on a version of the DLL.

  

2. Then set in php.ini

  

3, log.php in the code, note: Here is the use of Publish-subscribe mode, from PHP to publish,client small tools to do subscribe, is the relationship between the two.

<?php    $context = new Zmqcontext ();    $publisher = $context->getsocket (zmq::socket_pub);    $publisher->bind ("tcp://*:5555");    Sleep (1);     $publisher->send (' hello ');    Echo ' has sent Hello ';? >

Third, the client code

1, a total of two files, the client is can directly run EXE file, MyLog is. NET source code, edited with VS2010. Open the client file and just click Mylog.exe to open the gadget.

    

2. Clrzmq.dll is a ZMQ auxiliary DLL file in. NET and needs to be introduced into the source code.

3, in the client do ZMQ sub operation, receive and print out the data.

void Logreceiver ()        {            using (zmqcontext CTX = Zmqcontext.create ())            {                using (zmqsocket sub = CTX). Createsocket (sockettype.sub))                {                    SUB. Connect ("tcp://" + address.) Text + ":" + port. Text);                    Sub. Subscribeall ();                    Sub. Receiveready + = (s, e) + =                    {                        string log = Sub. Receive (Encoding.UTF8);                        Handlelog (log);                    };                    var poller = new Poller (new List<zmqsocket> {sub});                    while (_recvgo)                    {                        try                        {                            poller. Poll ();                        }                        catch (Exception ex)                        {                        }                    }            }}        }

There are still a lot of problems in integrating into the actual project, and I'm just going to show you a simple demo.

Demo Download:

http://download.csdn.net/detail/loneleaf1/7981505

Resources:

HTTP://ZEROMQ.ORG/ZMQ Home

HTTP://PECL.PHP.NET/PACKAGE/ZMQ php dll download

Study and study of Http://news.cnblogs.com/n/154000/ZMQ

HTTPS://GITHUB.COM/ZEROMQ/CLRZMQ clrzmq-official 0MQ Bindings for. NET and Mono

PHP Log always view gadgets

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.