You are on page 1of 3

UNIT-VIII Networking

UNIT-VIII Networking Basics of network programming Network: More than one computer systems are connected to sent and receive the information with each other is considered as a Network. due to the networking there is a communication between the systems. So, that they are shared data as well as resources. Internet: An interconnection of networks is considered as a internet or intranet( Local Area Network . !t is the name for vast of worldwide systems, which consists of different types of networks or different servers. "he computers that are connected to the !nternet is considered as a #ost. Socket Overview: Networks sockets are used for networking the systems. A Network socket is like an electrical socket at which various plugs around the network has a standard way of delivering their payload. $or transmission the data, the sockets are used some protocols.

Protocol is a standard set of rules, which is used to transfer the data from one system to another.
%rotocols are classified into two types as &onnection oriented protocols: 'g: "&%(!% %rotocols &onnection)less %rotocols 'g: *+% %rotocols Internet Protocol(IP) is a low)level routing protocol that breaks data into small packets and sends them to an address across the network. !t is not guarantee to deliver the packets to destination. Transmission Control Protocol(TCP) is a higher level protocol that manages to robustly string together these packets, sorting and retransmitting them as necessary to reliably tranmit the data. User Datagram Protocol(UDP) used directly to support fast, connectionless, unreliable transfer of packets.

resses:

,hen there are tens of millions of computers that are connected in a single network, an addressing scheme can be used to select an application that is running on any one of those multiple computers. "he computers connected with in an internet have addresses called !% addresses. "his address has the form Num1.Num2.Num3.Num4 "here are four numbers separated with dots and each number can have any value between - and .// $or e0ample: 12...3.145.6/ Another way of designating a particular computer is through domain name address. "he domain names are similar to that of !% addresses as they are written as a se7uence of items that are separated by periods(dots .+omain names point to a particular machine through multiple levels. "he levels on the right are more general and as they are read to the left, they become more specific. '0ample. www.8ntu.edu.in

8.1

Prepared by PHANI KISHORE ROMPICHRLA

UNIT-VIII Networking

Port: A 9ocation where the clients and servers can e0change information is called a port. %orts can be designated using integer numbers. "he numbers that are less than 1-.: are reserved for predefined services such as file transfer, email etc. So, a user defined port can have an integer value that is greater than 1-.:.
Simple client server program
program on Server si e!

import 8ava.net.;< class server = public static void main(String arg>? throws '0ception = System.out.println(@Server Activated@ < !netAddress aA!netAddress.get9ocal#ost( < Socket sAnew Socket(a,1-5- <(( or u can put localhost instead of Inetaddress a B B
program on client si e!

import 8ava.net.;< import 8ava.util.;< class client = public static void main(String arg>? throws '0ception = System.out.println(@&lient Activated@ < ServerSocket ssAnew ServerSocket(1-5- < Socket sAss.accept( < +ate dAnew +ate( < System.out.println(d.toString( < B B
//Write output & explanation in your words.

Multiple clients:
//Write above server/client progra . !ut in case client progra s u need write sa e client progra for few ti es".. i.e

class client1 = public static void main(String arg>? throws '0ception = 8.2 Prepared by PHANI KISHORE ROMPICHRLA

UNIT-VIII Networking

System.out.println(@&lient1 Activated@ < ServerSocket ssAnew ServerSocket(1-5- < Socket sAss.accept( < +ate dAnew +ate( < System.out.println(Cdate at client 1DEd.toString( < B B class client. = public static void main(String arg>? throws '0ception = System.out.println(@&lient. Activated@ < ServerSocket ssAnew ServerSocket(1-5- < Socket sAss.accept( < +ate dAnew +ate( < System.out.println(Cdate at client .DEd.toString( < B B

((* must write server side program too (( Fefer Funning notes too
Attempt ! "#estions $Start wit% well-known one& 'a(im#m tr) to write to programs * s)nta(es for eac% "#estion +ase on marks ,on-t forget to write comment lines for eac% program$# can get ma( marks& Use pencil for #n erlining important sentences or wor s etc. at t%e en of t%e e(am for ever) s#+/ect 'inim#m # nee #se one paper$0 pages& for 1 mark "#estion an 0 papers$2 pages& for 34 mark "#estion for ever) s#+/ect on-t strike an)t%ing 5 tr) to keep wrong +lock in +rackets or in comment lines ALL T67 B7ST U8S-at)am

8.3

Prepared by PHANI KISHORE ROMPICHRLA

You might also like