Quote Originally Posted by blacksource
...now, my question is that client A and client B send UDP messages to NAT B and NAT A without server S, whether the communication can be build.
No. Without the server S, the communication cannot be established.

The technique described in the article is called "hole punching". The"hole punching" technique is described in the excellent paper "Peer-to-Peer Communication Across Network Address Translators" by Bryan Ford, Pyda Srisuresh, Dan Kegel at http://www.brynosaurus.com/pub/net/p2pnat/ . Bryan Ford's site (at http://midcom-p2p.sourceforge.net/ ) includes a link to source code for "hole punching".

However, "hole punching" relies on the server S, which is sometimes called a "rendezvous server".

Quote Originally Posted by blacksource
... ihave seen the programs from Matthew Millman and Yi Hai, but they all work on LAN only.
These programs will (probably) work across a WAN too. However, to work across a WAN, each user must know the external (public) IP address on the Internet (as opposed to the private and non-routable IP address on the LAN), and routers on both LANs must be configured to port-forward incoming connections to the correct machine on the LAN. This is more of a network configuration issue. The chat program itself is unaffected and does not need any changes; rather, you must configure the two LANs so that the chat programs can run correctly.

Mike