SlideShare a Scribd company logo
1 of 7
Download to read offline
Core Java

Debasish Pratihari

Networking:


Networking is the linking of two or more
computing devices together with a purpose of
sharing data and other resources.



Networks are built with a mix of computer
hardware and computer software.



In networking the communication language used
by computer devices is called protocol.



An IP address helps to uniquely identify a
device in the network.

Network Layers :

Application Layer
(HTTP, FTP,Telnet…)

Application Layer
(HTTP, FTP,Telnet…)

Transport Layer
( TCP, UDP )

Transport Layer
( TCP, UDP )

Network Layer
(IP,…)

Network Layer
(IP,…)

Link Layer
( Device driver,..)
(IP,…)

Link Layer
( Device driver,..)
(IP,…)
Physical Layer – Ethernet, wireless, etc…

Note :
 The OSI Model is
having seven layers.
 As a java
programmer you are
programming

Application
Layer.

IP Address :


An Internet Protocol (IP) address is a numerical
identification (logical address) that is assigned to
devices participating in a computer network.



It is a 32-bit number(4-octects)



Example :192.168.1.1



Note :
The IP address in IPv6
is 128 bit. However
IPv4 is still in use and
will be in use for some
more years.

When a computer is configured to use the same IP
address each time it powers up, this is known as a
Static IP address. In contrast, in situations when
the computer's IP address is assigned automatically,
it is known as a Dynamic IP address.

Lecture/core/networking/25

Page #1

feel the Technology…
Core Java
Port :
 Is a logical connection
Network.

Debasish Pratihari

end-point in the



Transport Layer protocols specify a source and
destination port number in their packet header.



A port number is a 16-bit unsigned integer(065,535).



A process associates with a particular port
(called binding) to send and receive data.



Port number 0- 1023 are knows as wellknown ports

Application Layer:


The Application Layer involves all the user
related programs like web browsers and ftp.



The application layer programs use various
protocols:

HTTP
FTP
Telnet
SMTP

Hyper Text Transfer Protocol
File Transfer Protocol
the telnet protocol provides for
console sessions.
Simple Mail Transport Protocol email.

Lecture/core/networking/25

Page #2

feel the Technology…
Core Java

Debasish Pratihari

URL:


Browsers obtain resources from the Web by
specifying the Web addresses, which are
referred to officially as Uniform Resource
Locators (URL).



Example :



URL components :
o Protocol identifier
o Resource Name



A general Format of URLs :

http://www.lakshyatraining.org/

Protocol_ID://Host_IP_address:Port/Filename#Target

Where
Protocol_ID

HTTP, FTP, etc

Host_IP_address Host name in either numerical IP or
hostname format
Port
default is 80
Filename
Target

Name of a hypertext web page or
other type of file. Default
index.htm[l]
optional reference address within a
Web page

Socket:



Sockets provide connections between applications
and allow streams of data to flow.
Java provides two kinds of sockets:
 Socket: provides a connection-oriented
protocol that behaves like telnet or ftp. The
connection remains active, even with no
communications occurring, until explicitly
broken.
 DatagramSocket:
o a connectionless protocol
o transfers datagram packets
o no fixed connection
o does not keep packets in order
o no guarantee a packet will arrive at its
destination

Lecture/core/networking/25

Page #3

Note :
 Socket uses

TCP/IP and

DatagramSocket
uses UDP protocol

feel the Technology…
Core Java

Debasish Pratihari

URL Example :
25%
import java.net.*;
import java.io.*;
public class URLDemo
{
public static void main (String[] args) {
if (args.length !=1) {
System.out.println ("Error: missing the url argument");
System.exit (0);
}

}

try {
URL url = new URL (args[0]);
System.out.println ("Protocol = " + url.getProtocol ());
System.out.println ("Host = " + url.getHost ());
System.out.println ("File name = " + url.getFile ());
System.out.println ("Port = " + url.getPort ());
System.out.println ("Target = " + url.getRef ());
}
catch (MalformedURLException e) {
System.out.println ("Bad URL = " + args[0]);
}
}

MalformedURLException :




Each of the four URL constructors throws a
MalformedURLException if the arguments to
the constructor refer to a null or unknown
protocol.
you cna handle this exception by embedding
try/catch to your
try {
URL myURL = new URL(. . .)
} catch (MalformedURLException e) {
...
// exception handler code here
...
}

Lecture/core/networking/25

Page #4

feel the Technology…
Core Java

Debasish Pratihari

Using Socket:
 A socket is one endpoint of a two-way
communication link between two programs
running on the network.
 A socket is bound to a port number so that the
TCP layer can identify the application that data
is destined to be sent.
 Basic Steps :






Open a socket.
Open an input stream and output stream to
the socket.
Read from and write to the stream according
to the server's protocol.
Close the streams.
Close the socket.

Java Sockets for connection oriented
Communication:
 Socket types:
o ServerSocket
o Socket
 To create a ServerSoket:
ServerSocket ss=
new ServerSocket(port,quelength);

Where
Port
- port number
queuelength -Specifies the number of clients that can
wait for a connection and pressed by the server. If the queue is
full client connection refused.



To accept a connection request from the
client:
Socket con= ss.accept();



To get the input/output stream:
Con.getInputStream();
Con.getOutputStream();



To send and receive data:
BufferedWriter br=
new BufferedWriter(newInputStreamWriter(
con.getOutputStream());
BufferedReader br= new BufferedReader(new
InputStreamReader(con.getInputStream());

Lecture/core/networking/25

Page #5

feel the Technology…
Core Java

Debasish Pratihari

Example :
Objective – To get the server date using Stream
Socket
Server Program
FileName-DayServer.java
import java.net.*;
import java.io.*;
import java.util.*;
public class DayServer{
private ServerSocket ss;
public static void main(String args[]) throws
IOException{
DayServer ds = new DayServer();
for(;;)
ds.serve();
}
public DayServer() throws IOException{
ss= new ServerSocket(13,5);
}
public void serve() throws IOException{
Socket s = null;
s = ss.accept();
BufferedWriter out = new BufferedWriter( new
OutputStreamWriter(s.getOutputStream()));

out.write("Day & Time :"+ (new
Date()).toString());
out.close();
s.close();
}
}

Lecture/core/networking/25

Page #6

feel the Technology…
Core Java

Debasish Pratihari

Client Programs
FileName – DayClient.java
import java.net.*;
import java.io.*;
import java.util.*;
public class DayClient {
String Host;
Socket soc;
public DayClient(String phost) throws
IOException{
this.Host=phost;
}
public void getDate() throws IOException{
soc= new Socket(Host,13);
BufferedReader br = new BufferedReader(new
InputStreamReader(soc.getInputStream()));
System.out.println(br.readLine());

br.close();
soc.close();
}
public static void main(String args[]) throws
IOException{
DayClient dc= new DayClient(args[0]);
dc.getDate();
}
}

To Run (in single system):
 Compile both the programs.
 Run the Server program first.
 Open a new command window and run the client
as follows:
 Java DayClient localhost

Lecture/core/networking/25

Page #7

feel the Technology…

More Related Content

What's hot

Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThAram Mohammed
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04Ankit Dubey
 
Internet Protocol
Internet ProtocolInternet Protocol
Internet Protocolguesta8dc1
 
Jaimin chp-7 - application layer- 2011 batch
Jaimin   chp-7 - application layer- 2011 batchJaimin   chp-7 - application layer- 2011 batch
Jaimin chp-7 - application layer- 2011 batchJaimin Jani
 
Protocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteProtocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteAtharaw Deshmukh
 
Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report SlidesBassam Kanber
 
Role of OSI Layer when we open a webpage
Role of OSI Layer when we open a webpageRole of OSI Layer when we open a webpage
Role of OSI Layer when we open a webpageB Shiv Shankar
 
Network protocols and Java programming
Network protocols and Java programmingNetwork protocols and Java programming
Network protocols and Java programmingdifatta
 
Application layer protocol
Application layer protocolApplication layer protocol
Application layer protocolDr. Amitava Nag
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket ProgrammingMousmi Pawar
 

What's hot (20)

Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 Th
 
java networking
 java networking java networking
java networking
 
Chapter 2.1 : Data Stream
Chapter 2.1 : Data StreamChapter 2.1 : Data Stream
Chapter 2.1 : Data Stream
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04
 
internet protocol
internet protocolinternet protocol
internet protocol
 
Internet protocols
Internet protocolsInternet protocols
Internet protocols
 
Internet Protocols
Internet ProtocolsInternet Protocols
Internet Protocols
 
Web design EJ3
Web design    EJ3Web design    EJ3
Web design EJ3
 
Internet Protocol
Internet ProtocolInternet Protocol
Internet Protocol
 
Jaimin chp-7 - application layer- 2011 batch
Jaimin   chp-7 - application layer- 2011 batchJaimin   chp-7 - application layer- 2011 batch
Jaimin chp-7 - application layer- 2011 batch
 
Protocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol SuiteProtocols and the TCP/IP Protocol Suite
Protocols and the TCP/IP Protocol Suite
 
Overview of TCP IP
Overview of TCP IPOverview of TCP IP
Overview of TCP IP
 
Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report Slides
 
IP Datagram Structure
IP Datagram StructureIP Datagram Structure
IP Datagram Structure
 
Role of OSI Layer when we open a webpage
Role of OSI Layer when we open a webpageRole of OSI Layer when we open a webpage
Role of OSI Layer when we open a webpage
 
Chapter3
Chapter3Chapter3
Chapter3
 
Network protocols and Java programming
Network protocols and Java programmingNetwork protocols and Java programming
Network protocols and Java programming
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
 
Application layer protocol
Application layer protocolApplication layer protocol
Application layer protocol
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 

Viewers also liked

Building Scalable Web Apps
Building Scalable Web AppsBuilding Scalable Web Apps
Building Scalable Web Appszeeg
 
Preso zeeman smc013 01 25-47
Preso zeeman smc013 01 25-47Preso zeeman smc013 01 25-47
Preso zeeman smc013 01 25-47Sjef Kerkhofs
 
Learning Pool Customer of the Year Awards 2011
Learning Pool Customer of the Year Awards 2011Learning Pool Customer of the Year Awards 2011
Learning Pool Customer of the Year Awards 2011Paul McElvaney
 
Webinar: Upravljanje poslom - produktivnost u praksi
Webinar: Upravljanje poslom - produktivnost u praksiWebinar: Upravljanje poslom - produktivnost u praksi
Webinar: Upravljanje poslom - produktivnost u praksiMaja Vujovic
 
Gráfico junho 2010 colorido
Gráfico junho 2010 coloridoGráfico junho 2010 colorido
Gráfico junho 2010 coloridoNelson Silva
 
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...Paul McElvaney
 
Tipos de texto
Tipos de textoTipos de texto
Tipos de textocubs2000
 
Kako uspešno primeniti e-učenje
Kako uspešno primeniti e-učenjeKako uspešno primeniti e-učenje
Kako uspešno primeniti e-učenjeMaja Vujovic
 
Ima Apps Mania Event 2011
Ima Apps Mania Event 2011Ima Apps Mania Event 2011
Ima Apps Mania Event 2011Udi Salant
 
Pedraviva - 16.04.07
Pedraviva - 16.04.07Pedraviva - 16.04.07
Pedraviva - 16.04.07Jubrac Jacui
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Paul McElvaney
 
Learning Pool Social Care Seminar
Learning Pool Social Care SeminarLearning Pool Social Care Seminar
Learning Pool Social Care SeminarPaul McElvaney
 
Presentación azalpen. Tráfico web y conversión.
Presentación azalpen. Tráfico web y conversión.Presentación azalpen. Tráfico web y conversión.
Presentación azalpen. Tráfico web y conversión.Ibon Orrantia
 
Managing Live Chats Webinar
Managing Live Chats WebinarManaging Live Chats Webinar
Managing Live Chats WebinarPaul McElvaney
 
Launch of Tendring's District Council e-learning TREVOR
Launch of Tendring's District Council e-learning TREVORLaunch of Tendring's District Council e-learning TREVOR
Launch of Tendring's District Council e-learning TREVORPaul McElvaney
 

Viewers also liked (20)

Building Scalable Web Apps
Building Scalable Web AppsBuilding Scalable Web Apps
Building Scalable Web Apps
 
6 formatos
6 formatos6 formatos
6 formatos
 
Preso zeeman smc013 01 25-47
Preso zeeman smc013 01 25-47Preso zeeman smc013 01 25-47
Preso zeeman smc013 01 25-47
 
Learning Pool Customer of the Year Awards 2011
Learning Pool Customer of the Year Awards 2011Learning Pool Customer of the Year Awards 2011
Learning Pool Customer of the Year Awards 2011
 
Webinar: Upravljanje poslom - produktivnost u praksi
Webinar: Upravljanje poslom - produktivnost u praksiWebinar: Upravljanje poslom - produktivnost u praksi
Webinar: Upravljanje poslom - produktivnost u praksi
 
Gráfico junho 2010 colorido
Gráfico junho 2010 coloridoGráfico junho 2010 colorido
Gráfico junho 2010 colorido
 
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...
'Social Care - a provision through e-learning', Carol Judge, Warwickshire Cou...
 
Tipos de texto
Tipos de textoTipos de texto
Tipos de texto
 
Kako uspešno primeniti e-učenje
Kako uspešno primeniti e-učenjeKako uspešno primeniti e-učenje
Kako uspešno primeniti e-učenje
 
Gary Pyke, SLSA Wales
Gary Pyke, SLSA WalesGary Pyke, SLSA Wales
Gary Pyke, SLSA Wales
 
Lezing abc
Lezing abcLezing abc
Lezing abc
 
Ima Apps Mania Event 2011
Ima Apps Mania Event 2011Ima Apps Mania Event 2011
Ima Apps Mania Event 2011
 
Pedraviva - 16.04.07
Pedraviva - 16.04.07Pedraviva - 16.04.07
Pedraviva - 16.04.07
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
 
Learning Pool Social Care Seminar
Learning Pool Social Care SeminarLearning Pool Social Care Seminar
Learning Pool Social Care Seminar
 
Presentación azalpen. Tráfico web y conversión.
Presentación azalpen. Tráfico web y conversión.Presentación azalpen. Tráfico web y conversión.
Presentación azalpen. Tráfico web y conversión.
 
Scmad Chapter13
Scmad Chapter13Scmad Chapter13
Scmad Chapter13
 
Managing Live Chats Webinar
Managing Live Chats WebinarManaging Live Chats Webinar
Managing Live Chats Webinar
 
Scmad Chapter11
Scmad Chapter11Scmad Chapter11
Scmad Chapter11
 
Launch of Tendring's District Council e-learning TREVOR
Launch of Tendring's District Council e-learning TREVORLaunch of Tendring's District Council e-learning TREVOR
Launch of Tendring's District Council e-learning TREVOR
 

Similar to Core Java Networking Guide - 40 Character

Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Networking
NetworkingNetworking
NetworkingTuan Ngo
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptxRoshniSundrani
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaiDhawalVaja
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Javasuraj pandey
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaVijiPriya Jeyamani
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagarNitish Nagar
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in javaAmol Gaikwad
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat applicationSamsil Arefin
 

Similar to Core Java Networking Guide - 40 Character (20)

Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Networking
NetworkingNetworking
Networking
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
 
Socket Programming by Rajkumar Buyya
Socket Programming by Rajkumar BuyyaSocket Programming by Rajkumar Buyya
Socket Programming by Rajkumar Buyya
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Sockets
SocketsSockets
Sockets
 
Networking
NetworkingNetworking
Networking
 
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriyaIPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
IPT Chapter 2 Web Services and Middleware - Dr. J. VijiPriya
 
Networking in java
Networking in javaNetworking in java
Networking in java
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Java networking
Java networkingJava networking
Java networking
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Socket
SocketSocket
Socket
 
CS6551 COMPUTER NETWORKS
CS6551 COMPUTER NETWORKSCS6551 COMPUTER NETWORKS
CS6551 COMPUTER NETWORKS
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
Java 1
Java 1Java 1
Java 1
 

More from Debasish Pratihari (20)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Recently uploaded

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Recently uploaded (20)

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Core Java Networking Guide - 40 Character

  • 1. Core Java Debasish Pratihari Networking:  Networking is the linking of two or more computing devices together with a purpose of sharing data and other resources.  Networks are built with a mix of computer hardware and computer software.  In networking the communication language used by computer devices is called protocol.  An IP address helps to uniquely identify a device in the network. Network Layers : Application Layer (HTTP, FTP,Telnet…) Application Layer (HTTP, FTP,Telnet…) Transport Layer ( TCP, UDP ) Transport Layer ( TCP, UDP ) Network Layer (IP,…) Network Layer (IP,…) Link Layer ( Device driver,..) (IP,…) Link Layer ( Device driver,..) (IP,…) Physical Layer – Ethernet, wireless, etc… Note :  The OSI Model is having seven layers.  As a java programmer you are programming Application Layer. IP Address :  An Internet Protocol (IP) address is a numerical identification (logical address) that is assigned to devices participating in a computer network.  It is a 32-bit number(4-octects)  Example :192.168.1.1  Note : The IP address in IPv6 is 128 bit. However IPv4 is still in use and will be in use for some more years. When a computer is configured to use the same IP address each time it powers up, this is known as a Static IP address. In contrast, in situations when the computer's IP address is assigned automatically, it is known as a Dynamic IP address. Lecture/core/networking/25 Page #1 feel the Technology…
  • 2. Core Java Port :  Is a logical connection Network. Debasish Pratihari end-point in the  Transport Layer protocols specify a source and destination port number in their packet header.  A port number is a 16-bit unsigned integer(065,535).  A process associates with a particular port (called binding) to send and receive data.  Port number 0- 1023 are knows as wellknown ports Application Layer:  The Application Layer involves all the user related programs like web browsers and ftp.  The application layer programs use various protocols: HTTP FTP Telnet SMTP Hyper Text Transfer Protocol File Transfer Protocol the telnet protocol provides for console sessions. Simple Mail Transport Protocol email. Lecture/core/networking/25 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari URL:  Browsers obtain resources from the Web by specifying the Web addresses, which are referred to officially as Uniform Resource Locators (URL).  Example :  URL components : o Protocol identifier o Resource Name  A general Format of URLs : http://www.lakshyatraining.org/ Protocol_ID://Host_IP_address:Port/Filename#Target Where Protocol_ID HTTP, FTP, etc Host_IP_address Host name in either numerical IP or hostname format Port default is 80 Filename Target Name of a hypertext web page or other type of file. Default index.htm[l] optional reference address within a Web page Socket:   Sockets provide connections between applications and allow streams of data to flow. Java provides two kinds of sockets:  Socket: provides a connection-oriented protocol that behaves like telnet or ftp. The connection remains active, even with no communications occurring, until explicitly broken.  DatagramSocket: o a connectionless protocol o transfers datagram packets o no fixed connection o does not keep packets in order o no guarantee a packet will arrive at its destination Lecture/core/networking/25 Page #3 Note :  Socket uses TCP/IP and DatagramSocket uses UDP protocol feel the Technology…
  • 4. Core Java Debasish Pratihari URL Example : 25% import java.net.*; import java.io.*; public class URLDemo { public static void main (String[] args) { if (args.length !=1) { System.out.println ("Error: missing the url argument"); System.exit (0); } } try { URL url = new URL (args[0]); System.out.println ("Protocol = " + url.getProtocol ()); System.out.println ("Host = " + url.getHost ()); System.out.println ("File name = " + url.getFile ()); System.out.println ("Port = " + url.getPort ()); System.out.println ("Target = " + url.getRef ()); } catch (MalformedURLException e) { System.out.println ("Bad URL = " + args[0]); } } MalformedURLException :   Each of the four URL constructors throws a MalformedURLException if the arguments to the constructor refer to a null or unknown protocol. you cna handle this exception by embedding try/catch to your try { URL myURL = new URL(. . .) } catch (MalformedURLException e) { ... // exception handler code here ... } Lecture/core/networking/25 Page #4 feel the Technology…
  • 5. Core Java Debasish Pratihari Using Socket:  A socket is one endpoint of a two-way communication link between two programs running on the network.  A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent.  Basic Steps :      Open a socket. Open an input stream and output stream to the socket. Read from and write to the stream according to the server's protocol. Close the streams. Close the socket. Java Sockets for connection oriented Communication:  Socket types: o ServerSocket o Socket  To create a ServerSoket: ServerSocket ss= new ServerSocket(port,quelength); Where Port - port number queuelength -Specifies the number of clients that can wait for a connection and pressed by the server. If the queue is full client connection refused.  To accept a connection request from the client: Socket con= ss.accept();  To get the input/output stream: Con.getInputStream(); Con.getOutputStream();  To send and receive data: BufferedWriter br= new BufferedWriter(newInputStreamWriter( con.getOutputStream()); BufferedReader br= new BufferedReader(new InputStreamReader(con.getInputStream()); Lecture/core/networking/25 Page #5 feel the Technology…
  • 6. Core Java Debasish Pratihari Example : Objective – To get the server date using Stream Socket Server Program FileName-DayServer.java import java.net.*; import java.io.*; import java.util.*; public class DayServer{ private ServerSocket ss; public static void main(String args[]) throws IOException{ DayServer ds = new DayServer(); for(;;) ds.serve(); } public DayServer() throws IOException{ ss= new ServerSocket(13,5); } public void serve() throws IOException{ Socket s = null; s = ss.accept(); BufferedWriter out = new BufferedWriter( new OutputStreamWriter(s.getOutputStream())); out.write("Day & Time :"+ (new Date()).toString()); out.close(); s.close(); } } Lecture/core/networking/25 Page #6 feel the Technology…
  • 7. Core Java Debasish Pratihari Client Programs FileName – DayClient.java import java.net.*; import java.io.*; import java.util.*; public class DayClient { String Host; Socket soc; public DayClient(String phost) throws IOException{ this.Host=phost; } public void getDate() throws IOException{ soc= new Socket(Host,13); BufferedReader br = new BufferedReader(new InputStreamReader(soc.getInputStream())); System.out.println(br.readLine()); br.close(); soc.close(); } public static void main(String args[]) throws IOException{ DayClient dc= new DayClient(args[0]); dc.getDate(); } } To Run (in single system):  Compile both the programs.  Run the Server program first.  Open a new command window and run the client as follows:  Java DayClient localhost Lecture/core/networking/25 Page #7 feel the Technology…