Well in most of the tutorial of winsock programming they are usung the port 80 in the client as well as the server software.
Like
Why cant we use any other port .Code:addess.sin_port=htons(80);//where address is a name for my sockaddr_in structure
--------------------------------------------------------------------------------
And another thing is that when i am writing
in the client software I am connecting through port 80 with the computer whose ip address is 127.0.0.1(this is an internal ip address as methodz explained earlier)Code:addess.sin_port=htons(80) //converting port 80 to network byte order addess.sin_addr.s_addr=inet_addr( ("127.0.0.1");//converting the ip 127.0.0.1to network byte order
Similarly when i am writing
in the server software i am looking for a connection on port 80 from any ip addressCode:addess.sin_port=htons(80) //converting port 80 to network byte order addess.sin_addr.s_addr=INADDR_ANY;
AM I RIGHT in my conclusion of the above to code snippet??
Last edited by Jordan; 06-19-2008 at 01:22 PM.
Port 80 is actually the port most commonly used for web servers (the http port). I really don't know why the tutorials are recommending you to do that as it can cause clashes, probably just out of simplicity. You can however use any port you want to use, and it is actually best to use one out of the 1 to 1023 range, and out of the 1023 to 4---- (couldn't remember what this number was exactly) range, as those are the assigned ranges and company ranges. Above that is basically the wild wild west of port numbers and free to be used by anyone.
You are correct in your conclusion, however try to avoid using caps as it looks like you are yelling and telling everyone that your post is more urgent than everyone else.
INADDR_ANY -> signifies that you will be accepting connections from any address.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks