is someone know here how it possible to know if a port is in use or not

imagine you have your serveur who want toopen multiple listener socket

exple

while(kljfdlkljkdf)

if this port is ok listenat this port
else
port++