CSocket sock;
sock.Create();
for(int i=1;i<=1000;i++)
{
    if(sock.Connect("IP地址",i))
    {
      ........
      ........
    }}