A Network Socket is an Endpoint of an Inter

Embed Size (px)

Citation preview

  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    1/8

    Computer network programming involves writingcomputer programsthat enableprocessesto

    communicate with each other across acomputer network.

    A network socket is an endpoint of aninter-processcommunication flowacross acomputer network.

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

    socket.

    socket address is the combination of anIP addressand aport number

    socket is nothing but a communicational end point.while port is like an address for acomputer 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

    http://en.wikipedia.org/wiki/Computer_programshttp://en.wikipedia.org/wiki/Computer_programshttp://en.wikipedia.org/wiki/Computer_programshttp://en.wikipedia.org/wiki/Process_%28computing%29http://en.wikipedia.org/wiki/Process_%28computing%29http://en.wikipedia.org/wiki/Process_%28computing%29http://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Inter-process_communicationhttp://en.wikipedia.org/wiki/Inter-process_communicationhttp://en.wikipedia.org/wiki/Communication_flowhttp://en.wikipedia.org/wiki/Communication_flowhttp://en.wikipedia.org/wiki/Communication_flowhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/IP_addresshttp://en.wikipedia.org/wiki/IP_addresshttp://en.wikipedia.org/wiki/IP_addresshttp://en.wikipedia.org/wiki/Port_numberhttp://en.wikipedia.org/wiki/Port_numberhttp://en.wikipedia.org/wiki/Port_numberhttp://en.wikipedia.org/wiki/Port_numberhttp://en.wikipedia.org/wiki/IP_addresshttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Communication_flowhttp://en.wikipedia.org/wiki/Inter-process_communicationhttp://en.wikipedia.org/wiki/Computer_networkhttp://en.wikipedia.org/wiki/Process_%28computing%29http://en.wikipedia.org/wiki/Computer_programs
  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    2/8

    yourip:port above 1024

    IP address

    Anidentifierfor a computer ordevice on aTCP/IPnetwork. Networks using the TCP/IPprotocolroute 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 theInternetrequires using registered IP addresses(calledInternet addresses) to avoid duplicates.

    The four numbers in an IP address are used in different ways to identify a particular network anda host on that network. Four regional Internet registries --ARIN,RIPE NCC,LACNICand

    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

    CIDRis 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 deviceconnected 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 is216.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

    http://www.webopedia.com/TERM/I/identifier.htmlhttp://www.webopedia.com/TERM/I/identifier.htmlhttp://www.webopedia.com/TERM/I/identifier.htmlhttp://www.webopedia.com/TERM/D/device.htmlhttp://www.webopedia.com/TERM/D/device.htmlhttp://www.webopedia.com/TERM/T/TCP_IP.htmlhttp://www.webopedia.com/TERM/T/TCP_IP.htmlhttp://www.webopedia.com/TERM/N/network.htmlhttp://www.webopedia.com/TERM/N/network.htmlhttp://www.webopedia.com/TERM/N/network.htmlhttp://www.webopedia.com/TERM/P/protocol.htmlhttp://www.webopedia.com/TERM/P/protocol.htmlhttp://www.webopedia.com/TERM/I/Internet.htmlhttp://www.webopedia.com/TERM/I/Internet.htmlhttp://www.webopedia.com/TERM/I/Internet.htmlhttp://www.webopedia.com/TERM/I/IP_address.htmlhttp://www.webopedia.com/TERM/I/IP_address.htmlhttp://www.webopedia.com/TERM/I/IP_address.htmlhttp://www.webopedia.com/TERM/A/ARIN.htmlhttp://www.webopedia.com/TERM/A/ARIN.htmlhttp://www.webopedia.com/TERM/A/ARIN.htmlhttp://www.webopedia.com/TERM/R/RIPE_NCC.htmlhttp://www.webopedia.com/TERM/R/RIPE_NCC.htmlhttp://www.webopedia.com/TERM/R/RIPE_NCC.htmlhttp://www.webopedia.com/TERM/L/LACNIC.htmlhttp://www.webopedia.com/TERM/L/LACNIC.htmlhttp://www.webopedia.com/TERM/L/LACNIC.htmlhttp://www.webopedia.com/TERM/A/APNIC.htmlhttp://www.webopedia.com/TERM/A/APNIC.htmlhttp://www.webopedia.com/TERM/C/CIDR.htmlhttp://www.webopedia.com/TERM/C/CIDR.htmlhttp://www.webopedia.com/TERM/I/IPng.htmlhttp://www.webopedia.com/TERM/I/IPng.htmlhttp://www.webopedia.com/TERM/I/IPng.htmlhttp://www.webopedia.com/TERM/C/CIDR.htmlhttp://www.webopedia.com/TERM/A/APNIC.htmlhttp://www.webopedia.com/TERM/L/LACNIC.htmlhttp://www.webopedia.com/TERM/R/RIPE_NCC.htmlhttp://www.webopedia.com/TERM/A/ARIN.htmlhttp://www.webopedia.com/TERM/I/IP_address.htmlhttp://www.webopedia.com/TERM/I/Internet.htmlhttp://www.webopedia.com/TERM/P/protocol.htmlhttp://www.webopedia.com/TERM/N/network.htmlhttp://www.webopedia.com/TERM/T/TCP_IP.htmlhttp://www.webopedia.com/TERM/D/device.htmlhttp://www.webopedia.com/TERM/I/identifier.html
  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    3/8

    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 NetmaskCIDR /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.0CIDR /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 registeredwith the NetworkInformation 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 aprivate 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

  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    4/8

    blocks for private use. A private network is a network that uses RFC 1918IP address space. The

    following IP blocks are reserved for private IP addresses.

    Class Starting IP Address Ending IP Address

    A 10.0.0.0 10.255.255.255

    B 172.16.0.0 172.31.255.255C 192.168.0.0 192.168.255.255

    In addition to above classful private addresses, 169.254.0.0 through 169.254.255.255 addressesare 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.0subnet mask. A loopback interface is also known as a virtualIP, 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 usinghttp://127.0.0.1 or http://localhost.

    Definition: In computer networking, the term portcan refer to either physical or virtualconnection points.

    Physical network ports allow connecting cables to computers, routers, modems and otherperipheral devices. Several different types of physical ports available on computer network

    hardware include:

    Ethernetports 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 moreserialports and usually oneparallel

    port. The serial port supports sequential, one bit-at-a-time transmission to peripheral devices

    http://www.iplocation.net/rfc/rfc1918.phphttp://www.iplocation.net/rfc/rfc1918.phphttp://www.iplocation.net/rfc/rfc1918.phphttp://www.iplocation.net/tools/netmask.phphttp://www.iplocation.net/tools/netmask.phphttp://www.iplocation.net/tools/netmask.phphttp://compnetworking.about.com/cs/ethernet1/g/bldef_ethernet.htmhttp://compnetworking.about.com/cs/ethernet1/g/bldef_ethernet.htmhttp://compnetworking.about.com/od/usbnetworking/p/usb-port.htmhttp://compnetworking.about.com/od/usbnetworking/p/usb-port.htmhttp://searchcio-midmarket.techtarget.com/definition/serialhttp://searchcio-midmarket.techtarget.com/definition/serialhttp://searchcio-midmarket.techtarget.com/definition/serialhttp://searchcio-midmarket.techtarget.com/definition/parallelhttp://searchcio-midmarket.techtarget.com/definition/parallelhttp://searchcio-midmarket.techtarget.com/definition/parallelhttp://searchcio-midmarket.techtarget.com/definition/parallelhttp://searchcio-midmarket.techtarget.com/definition/serialhttp://compnetworking.about.com/od/usbnetworking/p/usb-port.htmhttp://compnetworking.about.com/cs/ethernet1/g/bldef_ethernet.htmhttp://www.iplocation.net/tools/netmask.phphttp://www.iplocation.net/rfc/rfc1918.php
  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    5/8

    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 "well-

    known 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 (serverprogram) initially is started, it is said tobindto its designated port number. As

    anyclientprogram wants to use that server, it also must request to bind to the designated portnumber.

    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 bespecified 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.Openstandard programminginterface(such as those specified in X/Open's1170Clanguage specification and Sun Microsystem'sJavaprogramming language) minimize or

    eliminate the work required to port a program. Also seeportability.

    Socket and ports

    In common language we can say that the socket is one of the most primal technologies ofcomputer networking. Sockets are just like an end-point of two-way communication, whichallow 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 sideconnection and second is server socket, which implement the server side connection.

    http://searchnetworking.techtarget.com/definition/TCP-IPhttp://searchnetworking.techtarget.com/definition/TCP-IPhttp://searchnetworking.techtarget.com/definition/TCP-IPhttp://searchcio-midmarket.techtarget.com/definition/IANAhttp://searchcio-midmarket.techtarget.com/definition/IANAhttp://searchcio-midmarket.techtarget.com/definition/IANAhttp://whatis.techtarget.com/definition/0,,sid9_gci212964,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci212964,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci212964,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci211662,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci211662,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci211662,00.htmlhttp://searchenterprisedesktop.techtarget.com/definition/clienthttp://searchenterprisedesktop.techtarget.com/definition/clienthttp://searchenterprisedesktop.techtarget.com/definition/clienthttp://searchnetworking.techtarget.com/definition/URLhttp://searchnetworking.techtarget.com/definition/URLhttp://searchnetworking.techtarget.com/definition/URLhttp://searchcio-midmarket.techtarget.com/definition/openhttp://searchcio-midmarket.techtarget.com/definition/openhttp://searchcio-midmarket.techtarget.com/definition/openhttp://searchcio-midmarket.techtarget.com/definition/interfacehttp://searchcio-midmarket.techtarget.com/definition/interfacehttp://searchcio-midmarket.techtarget.com/definition/interfacehttp://searchenterpriselinux.techtarget.com/definition/1170http://searchenterpriselinux.techtarget.com/definition/1170http://searchwinit.techtarget.com/definition/Chttp://searchwinit.techtarget.com/definition/Chttp://searchwinit.techtarget.com/definition/Chttp://searchsoa.techtarget.com/definition/Javahttp://searchsoa.techtarget.com/definition/Javahttp://searchsoa.techtarget.com/definition/Javahttp://searchstorage.techtarget.com/definition/portabilityhttp://searchstorage.techtarget.com/definition/portabilityhttp://searchstorage.techtarget.com/definition/portabilityhttp://www.roseindia.net/java/network/serversocket.shtmlhttp://www.roseindia.net/java/network/index.shtmlhttp://www.roseindia.net/java/network/client-server.shtmlhttp://www.roseindia.net/java/network/serversocket.shtmlhttp://www.roseindia.net/java/network/index.shtmlhttp://www.roseindia.net/java/network/client-server.shtmlhttp://www.roseindia.net/java/network/serversocket.shtmlhttp://www.roseindia.net/java/network/index.shtmlhttp://www.roseindia.net/java/network/client-server.shtmlhttp://searchstorage.techtarget.com/definition/portabilityhttp://searchsoa.techtarget.com/definition/Javahttp://searchwinit.techtarget.com/definition/Chttp://searchenterpriselinux.techtarget.com/definition/1170http://searchcio-midmarket.techtarget.com/definition/interfacehttp://searchcio-midmarket.techtarget.com/definition/openhttp://searchnetworking.techtarget.com/definition/URLhttp://searchenterprisedesktop.techtarget.com/definition/clienthttp://whatis.techtarget.com/definition/0,,sid9_gci211662,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci212964,00.htmlhttp://searchcio-midmarket.techtarget.com/definition/IANAhttp://searchnetworking.techtarget.com/definition/TCP-IP
  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    6/8

    The main purpose of the server socket is to listen an incoming connection request and ordinarysocket 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 bybinding 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 thenetwork. 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 aparticular 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 :-

  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    7/8

    Reserved port numbers.

    Service Port no.echo 7daytime 13ftp 21telnet 23smtp 25finger 79http 80pop3 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_ theletter 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

  • 7/31/2019 A Network Socket is an Endpoint of an Inter

    8/8