Yup ok i get it but why cant i just create a single socket
net=socket(AF_INET,SOCK_STREAM,0)
AND THE USE THIS SOCKET TO CONNECT TO ANOTHER HOST TRYING DIFFERENT PORT NUMBERS.I mean once the socket is made it can go in for loop try connecting if it is successful in creating a connection than print port number and than try another connection at different port..I guess it basically comes down to
'why do I need to make the socket call inside the for loop,Why not outside and use the socket created to make connection to host at differnt ports one at a time?'

2.Also this is obviously a very simple scanner and will be easily logged can anyone guide me how to go about making a stealth port scanner which can scan any host or at least give some decent result.