C#和PHP之间的通信 [英] communication between C # and PHP

查看:90
本文介绍了C#和PHP之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个C#应用程序,它从串口接收数据并保存mysql,它将数据发送到串口和答案。



我还有一个带有WAMP服务器的网站,允许从任何地方访问并将数据发送到串口来控制连接的设备。



问题:

如果C#中的应用程序正在使用它,我无法从PHP连接到串口。



解决方案:

将数据发送到C#for PHP应用程序,应用程序负责与串口交互。



我的问题:

如何从PHP向应用程序C#发送参数以及如何进行此处理。

Hi all, I have a C # application that receives data from the serial port and saves mysql, it sends data to the serial port and the answers.

Also I have a website with a WAMP server that allows access from anywhere and send data to the serial port to control the connected device.

problems:
I can not connect from PHP to the serial port if it is in use by the application in C #.

solution:
Send the data to C # for PHP application, and the application is what is responsible for interacting with the serial port.

My Question:
How I can send parameters to the application C # from PHP and how to make this process it.

推荐答案

有几种方法,具体取决于几个方面。根据你写的内容,你可以完全访问服务器,你可以安装和运行任何东西。

A)编写你的c#app作为命令行工具,只需从php调用它: http://www.php.net/manual/en/function.exec.php [<一个href =http://www.php.net/manual/en/function.exec.phptarget =_ blanktitle =新窗口> ^ ]

B你可以编写/使用sutom扩展到php来访问串口。请看这里: http://code.google.com/p/php-serial/ [ ^ ]

C)如果你的C# app是一种服务,或者是永久运行的,你可以使用一些IPC,比如MSMQ进行通信。在这里查看php端:

http://pastebin.com/S5uCiP2Z [ ^ ]和c#侧:使用C#中的MSMQ [ ^ ]

D)命名管道。 Php Side: http://my.opera.com/zomg/blog / 2007/08/29 / php-and-named-pipes [ ^ ],c#side: http://tech.pro/tutorial/633/interprocess-communication-using-named-pipes-in-csharp [ ^ ]



[更新了php msmq链接+命名管道选项]
There are several approaches, depending on several things. According to what you wrote, you have full access to the server, and you can install and run anything.
A) write your c# app as command line tool, and simply call it from php: http://www.php.net/manual/en/function.exec.php[^]
B) You could write/use a sutom extension to php to access the serial port. Look here: http://code.google.com/p/php-serial/[^]
C) If your C# app is a service, or is permanently running, you could use some IPC, like MSMQ to communicate. Look here for php side:
http://pastebin.com/S5uCiP2Z[^] and c# side respectively: Using MSMQ from C#[^]
D) Named pipes. Php Side: http://my.opera.com/zomg/blog/2007/08/29/php-and-named-pipes[^], c# side: http://tech.pro/tutorial/633/interprocess-communication-using-named-pipes-in-csharp[^]

[updated php msmq link + named pipe option]


这篇关于C#和PHP之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆