jbm
11-25-2002, 07:48 AM
Ok, I understand what is wrong with this but am not sure what to do about it ;)
Basically I want to use the connect function to try to connect to a port, then if successful print a message, otherwise go to the next port. So something like this:
while(i < 100) {
servaddr.sin_port = htons(i);
if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) == 0) {
printf("Server found at port %d", servaddr.sin_port);
close(sockfd);
}
i++;
}
Now note servaddr is a sockaddr_in that is set up correctly. The connect works and all (I watched netstat for a few minutes) - it tries to connect, but waits around 70seconds to time out if unsuccessful, then goes to the next port. Obviously I want a quicker scanner than that... So I am wondering what I should use to get a quicker response. I don't think it's possible to change the timeout for connect(), so I'm wondering if there is some other funtion I should use to try this.
This is just something for self educational purposes.. trying to learn more about network programming, no l337 shit duders.
Basically I want to use the connect function to try to connect to a port, then if successful print a message, otherwise go to the next port. So something like this:
while(i < 100) {
servaddr.sin_port = htons(i);
if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) == 0) {
printf("Server found at port %d", servaddr.sin_port);
close(sockfd);
}
i++;
}
Now note servaddr is a sockaddr_in that is set up correctly. The connect works and all (I watched netstat for a few minutes) - it tries to connect, but waits around 70seconds to time out if unsuccessful, then goes to the next port. Obviously I want a quicker scanner than that... So I am wondering what I should use to get a quicker response. I don't think it's possible to change the timeout for connect(), so I'm wondering if there is some other funtion I should use to try this.
This is just something for self educational purposes.. trying to learn more about network programming, no l337 shit duders.