Click here to Skip to main content
15,885,983 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi every one
i'll hope everything being ok
i have a valid ip on my laptop and in my laptop i have a local netrok
how can i write a program that i can access to this program
this is base on socket
everything is good
but maybe i should to use of setup NAT with use of my program
so now my code is base qt and c++
do you know can i do it??
in windows
Posted

1 solution

You do NOT need to implement NAPT in your software at all, as it should all be done by the firewall (in your setup, the router).

1) Learn about Windows Sockets (winsock), in particular pay attention to concept of source and destination addresses and port numbers.

2) Write a program which will implement communicatins between 2 PCs (I am assuming this is what you want to achieve at least). One will be the client the other will be the server.

3) Test the program in a setup where both client and server are on the same network (subnet). Make sure everything works correctly.

Below are the steps required if you want to, for example, allow external clients to connect to your server.

4) Set up NAT, or more correctly, NAPT in your router. You will need to map a port number to a local IP address that is not visible from outside your local network. For example, you can configure the router so that all external incoming connections on, for example, port 10100 are forwarded to IP address, for example, 192.168.0.5 (which is the IP address of the server on your local network).

5) The external client on the Internet should now be able to connect to the server if it uses the correct port number (as selected in step 4) and the correct public IP address of your router.

6) Your client-server program should work transparently with no software changes.
 
Share this answer
 
Comments
rpm3d 18-Dec-12 0:39am    
thank you i get your point..but i make all of your say before

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