Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Ports and sockets  RSS feed

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can anybody explain me what is port? How we define specific port on server. And what is difference between socket and ports?
Thanks in advance,
angela
 
Neeraj Thakkar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
You have made so many programs using ports and now u r asking what are ports?
Anyway a port can be in simple terms called as a door for a particular address. for e.g. There is a postman with an envelope in his hands to be delivered. He has got the address of a building (that is your computer) now he is to deliver it to a flat in a building how does he know it . As u have different flat numbers in one building u have different port numbers on ur system. There may be several programs running on ur system and all of them are accessing data from the net(A very good example is when u surf the net u have many browsers open and all of them want to access data from the net so how is it decided that which data should go to which browser.) So each application or browser listens at a apecific port number on ur system.
Now the data has reached the system or say that postman has reached the door AT THIS MOMENT there must be somebody to receive the data at the door. That is the work of socket. Each socket is bounded to a particular specific port number where it waits for the data to be received and also sends the data. So a socket is bound to a port which your program uses to communicate.
A port is a 16byte number so there can be 65535 ports on ur system. port number 0-1024 are called as well known ports as they are used by some known services so these port numbers should normally be not used by ur program.
Some well known port numbers as
25 - SMTP
110 - POP
80 - HTTP
and there are many many more for FTP,TELNET etc etc.
NEERAJ THAKKAR
------------------
 
Neeraj Thakkar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
In the reply I posted just I would like to correct the mistake that a port is a 16 bit number not byte.It is 2 bytes.
Plus I also forgot to add that a socket is responsible for aceepting data at the specified port and deliver it to the program / Application.
Thanks once again.
neeraj-thakkar@usa.net
------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!