Sei sulla pagina 1di 8

Computer network programming involves writing computer programs that enable processes to communicate with each other across

a computer network.

A network socket is an endpoint of an inter-process communication flow across a computer network.

A socket provides a bidirectional communication endpoint for sending and receiving data with another socket.

socket address is the combination of an IP address and a port number

socket is nothing but a communicational end point.while port is like an address for a
computer on networks
port is a software address on a computer on the network--for instance, the News server is a piece of software that is normally addressed through port 119, the POP server through port 110, the SMTP server through port 25, and so on. A socket is a communication path to a port. When you want your program to communicate over the network, you have given it a way of addressing the port and this is done by creating a socket and attaching it to the port. Basically, socket = IP + ports Sockets provide access to the port+ip

a port is nothing but a 16-bit number

port : a particular port number on a host socket: a host and a port like -> http port = 80 -> when you fire up google.com the socket on the server side is google.com:80 this is the server side socket on your local system where you are browsing the socket is

yourip:port above 1024

IP address
An identifier for a computer or device on a TCP/IP network. Networks using the TCP/IP protocol route messages based on the IP address of the destination. The format of an IP address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. For example, 1.160.10.240 could be an IP address. Within an isolated network, you can assign IP addresses at random as long as each one is unique. However, connecting a private network to the Internet requires using registered IP addresses (called Internet addresses) to avoid duplicates. The four numbers in an IP address are used in different ways to identify a particular network and a host on that network. Four regional Internet registries -- ARIN, RIPE NCC, LACNIC and APNIC -- assign Internet addresses from the following three classes. Class A - supports 16 million hosts on each of 126 networks Class B - supports 65,000 hosts on each of 16,000 networks Class C - supports 254 hosts on each of 2 million networks The number of unassigned Internet addresses is running out, so a new classless scheme called CIDR is gradually replacing the system based on classes A, B, and C and is tied to adoption of IPv6. Internet Protocol Address (or IP Address) is an unique address that computing devices use to identify itself and communicate with other devices in the Internet Protocol network. Any device connected to the IP network must have an unique IP address within its network. An IP address is analogous to a street address or telephone number in that it is used to uniquely identify a network device to deliver mail message, or call ("view") a website. Dotted Decimals The traditional IP Addresses (IPv4) uses a 32-bit number to represent an IP address, and it defines both network and host address. Due to IPv4 addresses running out, a new version of the IP protocol (IPv6) has been invented to offer virtually limitless number of unique addresses. An IP address is written in "dotted decimal" notation, which is 4 sets of numbers separated by period each set representing 8-bit number ranging from (0-255). An example of IPv4 address is 216.3.128.12, which is the IP address assigned to topwebhosts.org. An IPv4 address is divided into two parts: network and host address. The network address determines how many of the 32 bits are used for the network address, and remaining bits for the host address. The host address can further divided into subnetwork and host number. Class A, B, C and CIDR networks

Traditionally IP network is classified as A, B or C network. The computers identified the class by the first 3 bits (A=000, B=100, C=110), while humans identify the class by first octet(8-bit) number. With scarcity of IP addresses, the class-based system has been replaced by Classless Inter-Domain Routing (CIDR) to more efficiently allocate IP addresses. Class Network Address Number of Hosts Netmask CIDR /4 240,435,456 240.0.0.0 CIDR /5 134,217,728 248.0.0.0 CIDR /6 67,108,864 252.0.0.0 CIDR /7 33,554,432 254.0.0.0 A /8 (1-126) 16,777,216 255.0.0.0 CIDR /9 8,388,608 255.128.0.0 CIDR /10 4,194,304 255.192.0.0 CIDR /11 2,097,152 255.224.0.0 CIDR /12 1,048,576 255.240.0.0 CIDR /13 524,288 255.248.0.0 CIDR /14 262,144 255.252.0.0 CIDR /15 131,072 255.254.0.0 B /16 (128-191) 65,534 255.255.0.0 CIDR /17 32,768 255.255.128.0 CIDR /18 16,384 255.255.192.0 CIDR /19 8,192 255.255.224.0 CIDR /20 4,096 255.255.240.0 CIDR /21 2,048 255.255.248.0 CIDR /22 1,024 255.255.252.0 CIDR /23 512 255.255.254.0 C /24 (192-223) 256 255.255.255.0 CIDR /25 128 255.255.255.128 CIDR /26 64 255.255.255.192 CIDR /27 32 255.255.255.224 CIDR /28 16 255.255.255.240 CIDR /29 8 255.255.255.248 CIDR /30 4 255.255.255.252 Note: (1) 127 Network Address reserved for loopback test. (2) Class D (224-247, Multicast) and Class E (248-255, Experimental) are not intended to be used in public operation. Public and Private IP Addresses In order to maintain uniqueness within global namespace, the IP addresses are publicly registered with the Network Information Center (NIC) to avoid address conflicts. Devices that need to be publicly identified such as web or mail servers must have a globally unique IP address, and they are assigned a public IP address. Devices that do not require public access may be assigned a private IP address, and make it uniquely identifiable within one organization. For example, a network printer may be assigned a private IP address to prevent the world from printing from it. To allow organizations to freely assign private IP addresses, the NIC has reserved certain address

blocks for private use. A private network is a network that uses RFC 1918 IP address space. The following IP blocks are reserved for private IP addresses. Class A B C Starting IP Address 10.0.0.0 172.16.0.0 192.168.0.0 Ending IP Address 10.255.255.255 172.31.255.255 192.168.255.255

In addition to above classful private addresses, 169.254.0.0 through 169.254.255.255 addresses are reserved for Zeroconf (or APIPA, Automatic Private IP Addressing) to automatically create the usable IP network without configuration.

What is loopback IP address? The loopback IP address is the address used to access itself. The IPv4 designated 127.0.0.1 as the loopback address with the 255.0.0.0 subnet mask. A loopback interface is also known as a virtual IP, which does not associate with hardware interface. On Linux systems, the loopback interface is commonly called lo or lo0. The corresponding hostname for this interface is called localhost. The loopback address is used to test network software without physically installing a Network Interface Card (NIC), and without having to physically connect the machine to a TCP/IP network. A good example of this is to access the web server running on itself by using http://127.0.0.1 or http://localhost.

Definition: In computer networking, the term port can refer to either physical or virtual connection points. Physical network ports allow connecting cables to computers, routers, modems and other peripheral devices. Several different types of physical ports available on computer network hardware include:

Ethernet ports USB ports

1) On computer and telecommunication devices, a port (noun) is generally a specific place for being physically connected to some other device, usually with a socket and plug of some kind. Typically, a personal computer is provided with one or more serial ports and usually one parallel port. The serial port supports sequential, one bit-at-a-time transmission to peripheral devices

such as scanners and the parallel port supports multiple-bit-at-a-time transmission to devices such as printers. 2) In programming, a port (noun) is a "logical connection place" and specifically, using the Internet's protocol, TCP/IP, the way a client program specifies a particular server program on a computer in a network. Higher-level applications that use TCP/IP such as the Web protocol, Hypertext Transfer Protocol, have ports with preassigned numbers. These are known as "wellknown ports" that have been assigned by the Internet Assigned Numbers Authority (IANA). Other application processes are given port numbers dynamically for each connection. When a service (server program) initially is started, it is said to bind to its designated port number. As any client program wants to use that server, it also must request to bind to the designated port number. Port numbers are from 0 to 65535. Ports 0 to 1024 are reserved for use by certain privileged services. For the HTTP service, port 80 is defined as a default and it does not have to be specified in the Uniform Resource Locator (URL). 3) In programming, to port (verb) is to move an application program from an operating system environment in which it was developed to another operating system environment so it can be run there. Porting implies some work, but not nearly as much as redeveloping the program in the new environment. Open standard programming interface (such as those specified in X/Open's 1170 C language specification and Sun Microsystem's Java programming language) minimize or eliminate the work required to port a program. Also see portability.

Socket and ports


In common language we can say that the socket is one of the most primal technologies of computer networking. Sockets are just like an end-point of two-way communication, which allow applications to communicate using network hardware and operating systems. However in case of java never get confused with a socket. Socket classes are used to establish a connection between client program and a server program. In java there is a java.net package, which provides two types of classes- first is ordinary socket, which implement the client side connection and second is server socket, which implement the server side connection.

The main purpose of the server socket is to listen an incoming connection request and ordinary socket is used to ask to server for the connection. Once a connection between client and server established, both the connected socket can communicate with each other. In other hand we can consider the work of port in connection-based communication is like a medium through which, an application establish a connection with another application by binding a socket by a port number. Addressing the information and the port no., accompanied the data transfer over the network. The Ports are used by TCP and UDP to deliver the data to the right application, are identified by a 16-bit number. It will take effect of registering the application with the system to receive all data bound for that port. There is a limitation for the port that no port can be bound by two applications at the same time. Introduction of networking Ports In computer networking of connection-based communication port is like a medium through which, an application establish a connection with another application by binding a socket by a port number. Addressing the information and the port no., accompanied the data transfer over the network. The Ports are used by TCP and UDP to deliver the data to the right application, are identified by a 16-bit number present in the header of a data packet. Ports are typically used to map data to a particular process running on a client. If we consider a letter (data packet) sent to a particular apartment (IP) with house no. (port no), at this time the port no. is the most important part for the delivery of the letter. In order for the delivery to work, the sender needs to include an house number along with the address to ensure the letter gets to the right destination. If we consider the client-server architecture, a server application binds a socket to a specific port number in connection-based communication. It registered the server with the system where all the data destined for that port. Now we are aware of the importance of the port number. In the same order there are some ports which are predefine and called reserved ports. Some of them are given below :-

Reserved port numbers. Service Port no.


echo daytime ftp telnet smtp finger http pop3 7 13 21 23 25 79 80 110

If we consider the range of the port numbers, there are 0 to 65,535 ports available. The port numbers ranging from 0 - 1023 are reserved ports or we can say that are restricted ports. All the 0 to 1023 ports are reserved for use by well-known services such as FTP, telnet and http and other system services. These ports are called well-known ports.

They are both necessary for correctly routing traffic to its destination but have different scope. An IP address identifies a particular computer on the Internet. The port number identifies a particular program running on that computer.
Consider postal addresses by analogy. The street address and everything following identifies a particular residence or building, e.g. 1600 Pennsylvania Avenue, Washington DC. That is all the postal service needs to deliver a letter to its destination. However, once there it does not describe precisely _who_ the letter should go to. For that you need additional information - the name of the receipient. Only when this is also given - e.g. Bo the First Dog, 1600 Pennsylvania Avenue, Washington DC, can the letter be finally passed to the intended receipient. The port number works in the same way - the IP address is enough to get the data to the right computer but does not say which application should receive the data on that machine. That is what the port number does. For example, by convention anything sent to TCP port 80 will be forwarded to a web server running on that machine. Anything sent to port 21 is directed to the FTP server instead. Without the port numbers the operating system would have no idea what data is intended for which application.

The location where data is exchanged is called a port. Eg:- A USB port, at that location data is exchanged hence called a "port". A "ip address" is the unique identification number of a pc over the internet A "open port" is required for data transfer from the pc over the Ethernet port. If the port is closed there will be no transfer of data. The ip address is simply used to identify the pc over the network / internet using a unique number

port number is the number which provides services over internet. example 22 is port number for FTP it is the protocol which helps in downloading and uploading. ip address is the number assigned to the system to identify it on a network. example 192.168.1.1

Through logical address the system identify a network (source to destination). after identifying the network physical address is used to identify the host on that network. The port address is used to identify the particular application running on the destination machine. Logical Address: An IP address of the system is called logical address. This address is the combnation of Net ID and Host ID. This address is used by network layer to identify a particular network (source to destination) among the networks. This address can be changed by changing the host position on the network. So it is called logical address. Physical address: Each system having a NIC(Network Interface Card) through which two systems physically connected with each other with cables. The address of the NIC is called Physical address or mac address. This is specified by the manficture company of the card. This address is used by data link layer.

Port Address: There are many application running on the computer. Each application run with a port no.(logically) on the computer. This port no. for application is decided by the Karnal of the OS. This port no. is called port address. Read more: http://wiki.answers.com/Q/What_is_the_difference_between_port_address_logical_address_and _physical_address#ixzz1u5nf1CBw

Potrebbero piacerti anche