Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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++)
C++
...
iResult = getaddrinfo("how to get this ip?", what port ?, &hints, &result);//how to get ip/port of PHP server on specific domain name?
...

and

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


Thank you for your time :)
Posted
Comments
barneyman 20-Jan-15 20:23pm    
you don't need to go as low as winsock if you're talking to a web server - have a look at WinInet ( https://msdn.microsoft.com/en-us/library/windows/desktop/aa385473(v=vs.85).aspx )

1 solution

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


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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900