dqm4977 2011-09-20 11:52
浏览 199

PHP客户端通过TCP与C ++服务器通信

Im trying to get a Php page to be able to communicate with a C++ server. It must be able to recive and send at all time (and the same time). When the php page recives a string it shall make some changes in Mysql db but at the same time send other strings to the server.

You can think of it as a chat, but then the php recive a string it shall be formated.

The C++ server is up and running only the php client side is a mystery for me.

Is there any example code that anyone can help me with?

Thx!

  • 写回答

1条回答 默认 最新

  • dragonfly9527 2011-09-20 12:08
    关注

    Well first of all you need to understand and remember that PHP in itself is stateless. You can have PHP receive a request and parse it and do something with the gained information, but after that the request closes.

    One solution you could try is having your C++ app HTTP POST to a PHP script. This script can parse and analyze the request and take action upon it.

    1. Store something in the database
    2. Create a response
    3. Output the response

    The C++ app can then do something with the response.

    This will work but if your actual use case is a chatroom or something of the likes there are better solutions than using PHP.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP