问题
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