How do ports work on a network




















When information is sent over the Internet to your computer how does your computer accept that information? An easy way to understand ports is to imagine your IP address is a cable box and the ports are the different channels on that cable box.

The cable company knows how to send cable to your cable box based upon a unique serial number associated with that box IP Address , and then you receive the individual shows on different channels Ports. Ports work the same way. You have an IP address, and then many ports on that IP address. When I say many, I mean many. When a program on your computer sends or receives data over the Internet it sends that data to an ip address and a specific port on the remote computer, and receives the data on a usually random port on its own computer.

Note that once an application binds itself to a particular port, that port can not be used by any other application. It is first come, first served. This all probably still feels confusing to you, and there is nothing wrong with that, as this is a complicated concept to grasp.

Therefore, I will give you an example of how this works in real life so you can have a better understanding. We will use web servers in our example as you all know that a web server is a computer running an application that allows other computers to connect to it and retrieve the web pages stored there.

In order for a web server to accept connections from remote computers, such as yourself, it must bind the web server application to a local port. It will then use this port to listen for and accept connections from remote computers. Web servers typically bind to the TCP port 80, which is what the http protocol uses by default, and then will wait and listen for connections from remote devices.

Once a device is connected, it will send the requested web pages to the remote device, and when done disconnect the connection. On the other hand, if you are the remote user connecting to a web server it would work in reverse. Your web browser would pick a random TCP port from a certain range of port numbers, and attempt to connect to port 80 on the IP address of the web server.

When the connection is established, the web browser will send the request for a particular web page and receive it from the web server. Then both computers will disconnect the connection. Now, what if you wanted to run an FTP server, which is a server that allows you to transfer and receive files from remote computers, on the same web server.

Therefore, the FTP server application when it starts will bind itself to TCP ports 20 and 21, and wait for connections in order to send and receive data. Most major applications have a specific port that they listen on and they register this information with an organization called IANA. With developers registering the ports their applications use with IANA, the chances of two programs attempting to use the same port, and therefore causing a conflict, will be diminished.

Every machine on the the Internet has a unique number assigned to it, called an IP address. Yes you are doing that when you connect to two different websites as they both use port 80 rgds steve. So I have a question. Can server A somehow restrict me and only allow connections to the port on the remote server B and not allow me to connect me to any other port on remote server B?

Have you seen such a restriction before and if yes then what would be the reason behind such a restriction? Thank you. Not quite sure exactly what restriction you mean but you can restrict on destination port and ip and source port and IP if that helps rgds steve.

Hi Steve, So here is the scenario. The webserver A has the port open for any incoming requests. The webserver A hosts a website and one of the pages of that website has C code which makes API calls to a remote server B. So my questions are:- 1. Is it possible for the network admin to disallow API calls to ports other than ?

What could be the reason for such a restriction? After all, how can restricting a destination port give you any sort of advantage? Port is just a number on which the server listens. Please help. Yes you can filter incoming traffic on port, ip address and protocol even on basic firewalls. Restricting ports is for security reasons Rgds Steve. I want to read a data from a machine which supports open protocol if the machine is in network and if I know IP address and port number socket how can I read a data from it I know it send and receive data in packet format.

Thank you, Steve! Hi Not quite sure of what you mean exactly but load balancing is quite common. Question: When a program on your computer sends or receives data over the Internet it sends that data to an ip address and a specific port on the remote computer. How does my computer know what port a specific application is working on another computer to populate the TCP Header? When Machine A connects to machine B.

The source ip and port are contained in the connection packet as well as the destination port and IP address. Hi You need to use DNS. Most devices have MDNS enabled. Great site. I have a quick question. And it must also include its own IP address and port number. But it is not required to include its own IP address and port number. TCP is a connection orientated protocol and so the destination device needs to know who to send a reply to.

Can Server and client share the port number, eg : Server is listening at port num : and client also listens on the same port num : Yes providing they are on different hardware. Machines use 16bits for the port numbers hence the limitation of 64, Good job Steve. I have a question, and it goes like this: if i have 2 browsers from my PC connecting to the same service, for example both browsers are connecting to google.

Meaning can more than one socket connect to a socket at the same time? Yes they use the same IP and port on the Google server but different ports on the client. Hi, Thanks for this information sharing. It is very well explained. I have following doubt, What I understand is TCP protocol takes care of data transmission error that duplication of packets or packet in true form delivered to other end.

This is not done in UDP protocol. Could you please clear my doubt. Answer will help me alot. Google and Yaoo have different IP addresses. Does that make sense? The IP address of google and yahoo is different. The port number 80 is the open port of server. If I want to connect Google server,I will open a new port,for example I will open port , at the same time I will open another port to connect with Yahoo server.

I have few doubts though, hope you can clear them: 1. Can you tell if a server uses a single port 80 on all of its connections to clients? Or is it used only by the Welcoming socket? In computer networking , port numbers are part of the addressing information used to identify the senders and receivers of messages. Port numbers allow different applications on the same computer to share network resources simultaneously.

Home network routers and computer software work with these ports and sometimes support configuring port number settings. Networking ports are software-based and unrelated to physical ports that network devices have for plugging in cables. Port numbers relate to network addressing. These port numbers work like telephone extensions. Just as a business telephone switchboard can use the main phone number and assign each employee an extension number, a computer can have a main address and a set of port numbers to handle incoming and outgoing connections.

In the same way that all employees within a building can use one phone number, one IP address can be used to communicate with various applications behind one router. The IP address identifies the destination computer, and the port number identifies the specific destination application.

This is true whether it's a mail application, file transfer program, or web browser. When you request a website from a web browser, the browser communicates over port 80 for HTTP. Then, the data is sent back over the same port and displays in the program that supports that port the web browser. The network hardware and the software automatically process port numbers.

Casual users of a network do not see these port numbers and don't need to take any action involving their operation. Individuals can, however, encounter network port numbers in certain situations. Network administrators may need to set up port forwarding to allow the port numbers of specific applications to pass through a firewall. On home networks, a broadband router supports port forwarding on its configuration screens.

A common application of homeport forwarding is for online games that use non-standard ports that the router's built-in firewall blocks. Network programmers sometimes need to specify port numbers in their code, such as in socket programming.

This is usually seen in software development environments more than in mainstream consumer usage. Network security enthusiasts also frequently discuss the port number used as a key aspect of attack vulnerabilities and protections.



0コメント

  • 1000 / 1000