PHP Development CTP Trading System

Source: Internet
Author: User
Mainly want to use PHP to develop a CTP trading system, the CTP API using C + + write, do not know what tools to communicate, if using TCP services, is not to use C + + to write?
A bit chaotic, no specific ideas, the way Daniel, help, to provide the next ideas and tools oh, anxious to beg!

Reply content:

Mainly want to use PHP to develop a CTP trading system, the CTP API using C + + write, do not know what tools to communicate, if using TCP services, is not to use C + + to write?
A bit chaotic, no specific ideas, the way Daniel, help, to provide the next ideas and tools oh, anxious to beg!

The simple point is that PHP communicates with other language (C + +) APIs.
can use HTTP,TCP to communicate

See if you want to use HTTP or the lower-level TCP, UDP.

HTTP can only use CURL on the PHP side, or use a third-party library Guzzle .

If TCP or UDP, first consider the complexity of communication between your two services, if you simply send the data and then receive (that is, as the client, C + + that set as the server), can take advantage of PHP stream_socket_client , document reference: Http://php.net/manual/zh/func ...

Simply connect the code to send and receive data:

$fp = stream_socket_client("tcp://10.1.7.122:27710", $errno, $errstr, 5);// UDP 改一下 Schema 就好,如下:// $fp = stream_socket_client("udp://10.1.7.122:27710", $errno, $errstr, 5);if (!$fp) {    echo "$errstr ($errno)
\n";} else { fwrite($fp, pack("s", 666)); while (!feof($fp)) { $recv .= fread($fp, 1024); } fclose($fp);}

Complex points, which need to be serviced, may be considered Swoole orWorkerman

  • 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.