How to simulate a client server application I wrote in c++ using windows sockets?

时光怂恿深爱的人放手 提交于 2019-12-12 01:01:45

问题


I was asked recently to write a client server application so I did this using c++ and windows sockets and I tried it on two pcs on a LAN and it worked pretty well.My professor wants to see this working for real but I thought there could be a way to simulate that application and show that it works without having to connect two Pcs and so on....how can I do that?


回答1:


You dont have to simulate anything, just run it on one machine and use 127.0.0.1 (thats an address of localhost loopback) as an IP address. I believe you should have some way to specify server IP address on your client.




回答2:


You can connect to your "local address" in the same way as connecting to a remote host, just use 127.0.0.1 as the ip address.

Also, remember to use different ports for your server and client.




回答3:


Just run them on one machine though.

All you need is to have is a network interface configured for IP up'n'running.

There does not need to be any physical network cableing.

If also no physical network adapter is available the loopback device might be used. It could serve serves all addresses of the 127.0.0.0/255.0.0.0 subnet. Per default it is set up for the address 127.0.0.1. The loopback device comes with the TCP/IP stack.



来源:https://stackoverflow.com/questions/16120178/how-to-simulate-a-client-server-application-i-wrote-in-c-using-windows-sockets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!