If you detect someone trying to connect to a certain port you are listening on via /socklisten, you can accept the connection with /sockaccept, after which the $sock identifier becomes available to give you information.