Click here to Skip to main content
12,947,192 members (48,184 online)
Rate this:
Please Sign up or sign in to vote.
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 15-Dec-12 1:02am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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, (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.
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,059
CHill60 3,235
Maciej Los 2,538
Jochen Arndt 1,935
ppolymorphe 1,795

Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100