Without any connect/listen/bind, you need some OS magic to do it. For example in Windows you can try functions like GetExtendedTcpTable
or GetExtendedUdpTable
.
The GetExtendedUdpTable/GetExtendedTcpTable function retrieves a table that contains a list of UDP/TCP endpoints available to the application.
These retrieve lists so that you can iterate over it and get useful information. Check if any executing program is listening to that specific port or not.