如何从Windows winsock客户端连接到PHP服务器? [英] How to connect to PHP server from windows winsock client ?

查看:101
本文介绍了如何从Windows winsock客户端连接到PHP服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Windows PC客户端winsock发送数据,

到域名,如www.test.com/test/phpserver.php\"(username=user,password=pass),然后检索数据

问题:

如何从windows winsock客户端连接到PHP服务器?

如何获取/设置IP和端口?



Winsock PC客户端(c ++)

I want send data from my windows PC client winsock,
to domain name like "www.test.com/test/phpserver.php"(username=user,password=pass) and then retrieve data
Question:
How to connect to PHP server from windows winsock client?
How to get/set ip and port?

Winsock PC client (c++)

...
iResult = getaddrinfo("how to get this ip?", what port ?, &hints, &result);//how to get ip/port of PHP server on specific domain name?
...







PHP服务器TCP / IP服务器


and

PHP server TCP/IP server

...
$address = 'how to get this ip?';//at "www.test.com/test/phpserver.php"
$port = what port ?;
...





感谢您的时间:)



Thank you for your time :)

推荐答案

address = ' 如何获取此IP?'; // 位于www.test.com/test/phpserver.php
address = 'how to get this ip?';//at "www.test.com/test/phpserver.php"


port =什么端口?
...
port = what port ?; ...





感谢您的时间:)



Thank you for your time :)


简答题使用卷曲库



长期回答阅读下面:



我认为你的php服务器将运行到默认端口80或8080.如果不是你可以检查httpd.conf文件中的端口号。如果它是windows,那么你可以使用

Short answer use curl library

For Long answer read below :

I think ur php server will be running to default port 80 or 8080. If not u can check port number in httpd.conf file. If it is windows then u can use
On a newer version of WAMP, click the WAMP server icon > Apache > httpd.conf





对于ip如果机器相同则使用127.0.0.1,如果它是不同的服务器则运行ipconfig或你的php服务器机器的命令提示符(或终端)上的ifconfig命令。尝试首先从您想要放置ur exe的机器ping该ip。它必须ping,否则检查防病毒或可能是一些防火墙后面的内部IP。现在你得到了ip&端口,所以现在你可以尝试连接。这是非常低级别的连接。如果您的服务器以标记语言提供数据,那么您必须解析它。



For ip if machine is same then use 127.0.0.1, if it is different server then run "ipconfig" or "ifconfig" command on command prompt (or terminal) of ur php server machine. Try pinging that ip first from the machine where u want to put ur exe. It must ping otherwise check antivirus or may be that is internal ip behind some firewall. Now u got ip & port so now u can try to connect. This is very low level connection. If your server gives data in markup language then u have to parse that.


这篇关于如何从Windows winsock客户端连接到PHP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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