Code:
 if((new=connect(net,(struct sockaddr *)&sa,sizeof(sa)))>=0)
                {
                        printf("%d is open\n",i);
                }
Also why have you removed close(new).And yeah i added close(net) at the end