i understand how to create a socket and assign a port to a socket. But how can i make a for loop to auto assign 21 ports to it? need some helps!!!

Recommended Answers

All 4 Replies

You don't. One socket, one port. On the server side you can reserve a block of ports for use by the server's clients in the hosts file. The location of that file depends on the operating system. On my computer running Vista its located here:
D:\Windows\System32\drivers\etc

ok if i i wans to cretate 21 sockects wif 21 ports as all these 21 ports are for different thing! Instead of creating 21 hard coded sockects, i would like to make a for loop to auto create it

I would add the ports you want to use in the hosts file, then your program can read the host file to find out what ports to use.

thanks Ancient Dragon for ur help and info!!! i got wat u mean!!! thanks again!!! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.