Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

server - How to port forward automatically in java?

I know that bit torrent clients use automatic port forwarding (Port forwarding with having to configure the router) so that they can connect to each other. I want the users in my application to be able to host a server without having to configure the router. So I was wondering how you would do so in java?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use UPnP (Universal Plug and Play) port forwarding. One library mentioned is Cling, but there's much simpler library - WaifUPnP, which allows you to forward a port with just one line like:

UPnP.openTCP(portnumber);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...