I want to scan a port that a game uses, and get all the ip's that are connceted through that port to my server.

How can I do that and log those ip's to a txt file.