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