Develop the CTP transaction system in PHP

Source: Internet
Author: User
We mainly want to develop a CTP transaction system using PHP. The ctp api is written in C ++ and we don't know what tools to use for communication. if we use the tcp service, is it written in C ++? It's a bit messy and there's no specific way of thinking. you can help you and provide your ideas and tools. Please hurry! We mainly want to develop a CTP transaction system using PHP. The ctp api is written in C ++ and we don't know what tools to use for communication. if we use the tcp service, is it written in C ++?
It's a bit messy and there's no specific way of thinking. you can help you and provide your ideas and tools. Please hurry!

Reply content:

We mainly want to develop a CTP transaction system using PHP. The ctp api is written in C ++ and we don't know what tools to use for communication. if we use the tcp service, is it written in C ++?
It's a bit messy and there's no specific way of thinking. you can help you and provide your ideas and tools. Please hurry!

To put it simply, PHP communicates with APIs in other languages (C ++.
Both http and tcp can be used for communication.

Check whether you want to use HTTP or lower-layer TCP or UDP.

HTTP only needs to use cURL for PHP, or use a third-party library.Guzzle.

For TCP or UDP, consider the complexity of communication between your two services first. if you simply send and receive data (that is, use the client and C ++ as the server ), PHPstream_socket_client, Reference: http://php.net/manual/zh/func...

Code for simple connection to send and receive data:

$ Fp = stream_socket_client ("tcp: // 10.1.7.122: 27710", $ errno, $ errstr, 5); // modify the Schema using UDP, as shown below: // $ 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 );}

If you need to create a server, considerSwooleOrWorkerman

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.