View Single Post
Old 03-06-2010, 03:05 PM   #7
en_7123
Ambitious contributor
 
en_7123's Avatar
 
Join Date: Feb 2010
Posts: 105
Thanks: 0
Thanked 4 Times in 4 Posts
Rep Power: 1
en_7123 is on a distinguished road
Post

Re: Help with port scanner


Quote:
Originally Posted by karthigayan View Post
When you connect with the host , you can just connect with the single port only.Because each port is for a single connection .So you can not get all the port with the single connection.If you want to get the available ports you need to have multiple connection.so each connection will try to occupy the port which is available.There while you can get the available ports on the host ( This is what your second program doing and getting the ports correctly ).

Then you asked to store the ip in the char[].Since you want this as a string I said 16 bits is enough.But if you want to store that as a integer you need 32 bits. Infact to do some operaton with the ip address you need to store that as a integer only.
Ok i get it now but now I, making addr as int but when i take it as input scanf("%d",&addr)..The code compiles but on running no result.But when i define.
int addr;
scanf("%s",&addr);
it is working fine.So if IP needs to be in int why do we have to give %s in scanf.Do i make my addr in the code as int or char.
en_7123 is offline   Reply With Quote