SlideShare a Scribd company logo
Module 07 – Java Networking
Danairat T.
Line ID: Danairat
FB: Danairat Thanabodithammachari
+668-1559-1446
Fundamental Java Programming
The Course Outline
Module 01 – Introduction to Java
Module 02 – Basic Java Programming
Module 03 – Control Flow and Exception Handling
Module 04 – Object Oriented in Java
Module 05 – Java Package and Access Control
Module 06 – Java File IO
Module 07 – Java Networking
Module 08 – Java Threading
Module 07 – Java Networking
• Basic Networking
• Network Port Numbers
• Java Socket
• Writing Server Socket
• Writing Client Socket
• Passing Object over Network
Basic Networking
TCP: The protocol for two applications which are want to communicate to
each other reliably, they establish a connection and send data back and
forth over that connection. This is analogous to making a telephone call.
UDP: The protocol that is not guaranteed between two applications on the
network. UDP is not connection-based like TCP. Rather, it sends
independent packets of data, called datagrams, from one application to
another. Sending datagrams is much like sending a letter through the
postal service: The order of delivery is not important and is not
guaranteed, and each message is independent of any other.
Network Port Numbers
IP Address is a unique number of computer network address for
both server and client.
Ports are identified by a 16-bit number (65536 ports), which TCP
and UDP use to deliver the data to the right application.
The first 1024 port numbers have been reserved by system root
user. The rest port numbers can be use by other system users.
Java Socket
A socket is one end-point of a two-way communication link
between two programs running on the network. Socket
classes are used to represent the connection between a
client program and a server program. The java.net package
provides two classes--Socket and ServerSocket--that
implement the client side of the connection and the server
side of the connection, respectively.
Simple Socket Server
package javanetworkingproject;
import java.net.*;
import java.io.*;
public class MyServer {
public static void main(String args[]) throws IOException {
// Register service on port 1234
ServerSocket s = new ServerSocket(1234);
Socket s1= s.accept(); // Wait and accept a connection
// Get a communication stream associated with the socket
OutputStream s1out = s1.getOutputStream();
DataOutputStream dos = new DataOutputStream (s1out);
// Send a string!
dos.writeUTF("Hi there สวัสดี");
// Close the connection, but not the server socket
dos.close();
s1out.close();
s1.close();
}
}
Simple Client Server
import java.net.*;
import java.io.*;
public class MyClient {
public static void main(String args[]) throws IOException {
// Open your connection to a server, at port 1234
Socket s1 = new Socket("127.0.0.1",1234);
// Get result from server
InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
String st = new String (dis.readUTF());
System.out.println(st);
// When done, just close the connection and exit
dis.close();
s1In.close();
s1.close();
}
}
Hi there สวัสดี
Object Passing over network
import java.io.Serializable;
public class Customer implements Serializable{
private String name;
private int collectedPoints;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setCollectedPoints(int collectedPoints) {
this.collectedPoints = collectedPoints;
}
public int getCollectedPoints() {
return collectedPoints;
}
}
Server Socket Programming with Object Passing
package javanetworkingproject2;
import java.net.*;
import java.io.*;
public class MyServer2 {
public static void main(String[] args) throws Exception {
// Register service on port 1234
ServerSocket s = new ServerSocket(1234);
Socket s1 = s.accept(); // Wait and accept a connection
// Read input from client
ObjectInputStream objInputStream =
new ObjectInputStream(s1.getInputStream());
Customer cust1 = (Customer)objInputStream.readObject();
cust1.setCollectedPoints(3000);
// Write result to client
OutputStream s1out = s1.getOutputStream();
ObjectOutputStream objOutputStream = new ObjectOutputStream(s1out);
objOutputStream.writeObject(cust1);
// Close the connection, but not the server socket
objOutputStream.close();
s1out.close();
objInputStream.close();
s1.close();
}
}
Client Socket Programming with Object Passing
import java.net.*;
import java.io.*;
public class MyClient2 {
public static void main(String[] args) throws Exception {
// Open your connection to a server, at port 1234
Socket s1 = new Socket("127.0.0.1", 1234);
// Write object to the socket server
Customer cust1 = new Customer();
cust1.setName("Somchai");
ObjectOutputStream objOutputStream =
new ObjectOutputStream(s1.getOutputStream());
objOutputStream.writeObject(cust1);
// Get result from server
InputStream s1In = s1.getInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(s1In);
Customer custResult = (Customer)objInputStream.readObject();
System.out.println(custResult.getName() + " has " +
custResult.getCollectedPoints() + " points");
// When done, just close the connection and exit
objInputStream.close();
s1In.close();
objOutputStream.close();
s1.close();
}
}
URL Reader
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
URL googleURL = new URL("http://www.google.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
googleURL.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
Danairat T.
Line ID: Danairat
FB: Danairat Thanabodithammachari
+668-1559-1446
Thank you

More Related Content

What's hot (20)

Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
java networking
 java networking java networking
java networking
Waheed Warraich
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Java networking programs socket based
Java networking programs socket basedJava networking programs socket based
Java networking programs socket based
Mukesh Tekwani
 
Java Networking
Java NetworkingJava Networking
Java Networking
68SachinYadavSYCS
 
Java API: java.net.InetAddress
Java API: java.net.InetAddressJava API: java.net.InetAddress
Java API: java.net.InetAddress
Sayak Sarkar
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
UC San Diego
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Networking in java, Advanced programming
Networking in java, Advanced programmingNetworking in java, Advanced programming
Networking in java, Advanced programming
Gera Paulos
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
suraj pandey
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Chap 1 Network Theory & Java Overview
Chap 1   Network Theory & Java OverviewChap 1   Network Theory & Java Overview
Chap 1 Network Theory & Java Overview
Ministry of Higher Education
 
Java 1
Java 1Java 1
Java 1
VidyaVarshini3
 
28 networking
28  networking28  networking
28 networking
Ravindra Rathore
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
CEC Landran
 
Java networking
Java networkingJava networking
Java networking
ssuser3a47cb
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
Tushar B Kute
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
Rakesh Madugula
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
Mmanan91
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
Ebisa Bekele
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Java networking programs socket based
Java networking programs socket basedJava networking programs socket based
Java networking programs socket based
Mukesh Tekwani
 
Java API: java.net.InetAddress
Java API: java.net.InetAddressJava API: java.net.InetAddress
Java API: java.net.InetAddress
Sayak Sarkar
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
UC San Diego
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Networking in java, Advanced programming
Networking in java, Advanced programmingNetworking in java, Advanced programming
Networking in java, Advanced programming
Gera Paulos
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
suraj pandey
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
CEC Landran
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
Tushar B Kute
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
Mmanan91
 

Viewers also liked (18)

Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
kamal kotecha
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Sachintha Gunasena
 
Sockets
SocketsSockets
Sockets
sivindia
 
Stop guessing - make cashless payments a success
Stop guessing - make cashless payments a successStop guessing - make cashless payments a success
Stop guessing - make cashless payments a success
BSGAfrica
 
Jnp
JnpJnp
Jnp
hj43us
 
java packages
java packagesjava packages
java packages
aptechsravan
 
Email Security Threats: IT Manager's Eyes Only
Email Security Threats: IT Manager's Eyes Only Email Security Threats: IT Manager's Eyes Only
Email Security Threats: IT Manager's Eyes Only
Topsec Technology
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
 
Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5
geethawilliam
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
Jignesh Patel
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Digital signatures
Digital signaturesDigital signatures
Digital signatures
Ishwar Dayal
 
Lan chat system
Lan chat systemLan chat system
Lan chat system
Wipro
 
Digital signature
Digital signatureDigital signature
Digital signature
Hossain Md Shakhawat
 
Email
EmailEmail
Email
ARSD College
 
Digital Signature
Digital SignatureDigital Signature
Digital Signature
saurav5884
 
Core java slides
Core java slidesCore java slides
Core java slides
Abhilash Nair
 
Electronic mail
Electronic mailElectronic mail
Electronic mail
Diwaker Pant
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
kamal kotecha
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Sachintha Gunasena
 
Stop guessing - make cashless payments a success
Stop guessing - make cashless payments a successStop guessing - make cashless payments a success
Stop guessing - make cashless payments a success
BSGAfrica
 
Email Security Threats: IT Manager's Eyes Only
Email Security Threats: IT Manager's Eyes Only Email Security Threats: IT Manager's Eyes Only
Email Security Threats: IT Manager's Eyes Only
Topsec Technology
 
Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5
geethawilliam
 
Socket Programming Tutorial
Socket Programming TutorialSocket Programming Tutorial
Socket Programming Tutorial
Jignesh Patel
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Digital signatures
Digital signaturesDigital signatures
Digital signatures
Ishwar Dayal
 
Lan chat system
Lan chat systemLan chat system
Lan chat system
Wipro
 
Digital Signature
Digital SignatureDigital Signature
Digital Signature
saurav5884
 
Ad

Similar to Java Programming - 07 java networking (20)

Advanced Java Topics
Advanced Java TopicsAdvanced Java Topics
Advanced Java Topics
Salahaddin University-Erbil
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
EliasPetros
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
arnold 7490
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
leminhvuong
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
phanleson
 
Java
JavaJava
Java
Subha Selvam
 
Lecture6
Lecture6Lecture6
Lecture6
vantinhkhuc
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
17-Networking.pdf
17-Networking.pdf17-Networking.pdf
17-Networking.pdf
sophia763824
 
Socket & Server Socket
Socket & Server SocketSocket & Server Socket
Socket & Server Socket
Hemant Chetwani
 
Networking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programNetworking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in program
govindjha339843
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
javanetworking
javanetworkingjavanetworking
javanetworking
Arjun Shanka
 
Java socket programming
Java socket programmingJava socket programming
Java socket programming
Mohammed Abdalla Youssif
 
Chapter 4 slides
Chapter 4 slidesChapter 4 slides
Chapter 4 slides
lara_ays
 
Networking Basics1ofjavaprogramming.pptx.pdf
Networking Basics1ofjavaprogramming.pptx.pdfNetworking Basics1ofjavaprogramming.pptx.pdf
Networking Basics1ofjavaprogramming.pptx.pdf
omkarthombare4989
 
Socket Programming in Java.ppt yeh haii
Socket Programming in Java.ppt  yeh haiiSocket Programming in Java.ppt  yeh haii
Socket Programming in Java.ppt yeh haii
inambscs4508
 
Ipc
IpcIpc
Ipc
deepakittude
 
Networking
NetworkingNetworking
Networking
Tuan Ngo
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
EliasPetros
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
phanleson
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
RoshniSundrani
 
Networking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programNetworking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in program
govindjha339843
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Chapter 4 slides
Chapter 4 slidesChapter 4 slides
Chapter 4 slides
lara_ays
 
Networking Basics1ofjavaprogramming.pptx.pdf
Networking Basics1ofjavaprogramming.pptx.pdfNetworking Basics1ofjavaprogramming.pptx.pdf
Networking Basics1ofjavaprogramming.pptx.pdf
omkarthombare4989
 
Socket Programming in Java.ppt yeh haii
Socket Programming in Java.ppt  yeh haiiSocket Programming in Java.ppt  yeh haii
Socket Programming in Java.ppt yeh haii
inambscs4508
 
Networking
NetworkingNetworking
Networking
Tuan Ngo
 
Ad

More from Danairat Thanabodithammachari (20)

Thailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AMThailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AM
Danairat Thanabodithammachari
 
Agile Management
Agile ManagementAgile Management
Agile Management
Danairat Thanabodithammachari
 
Agile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 DanairatAgile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 Danairat
Danairat Thanabodithammachari
 
Blockchain for Management
Blockchain for ManagementBlockchain for Management
Blockchain for Management
Danairat Thanabodithammachari
 
Enterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 DanairatEnterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 Danairat
Danairat Thanabodithammachari
 
Agile Enterprise Architecture - Danairat
Agile Enterprise Architecture - DanairatAgile Enterprise Architecture - Danairat
Agile Enterprise Architecture - Danairat
Danairat Thanabodithammachari
 
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by DanairatDigital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Danairat Thanabodithammachari
 
Big data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guideBig data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guide
Danairat Thanabodithammachari
 
Big data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guideBig data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guide
Danairat Thanabodithammachari
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File Processing
Danairat Thanabodithammachari
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 
Perl Programming - 03 Programming File
Perl Programming - 03 Programming FilePerl Programming - 03 Programming File
Perl Programming - 03 Programming File
Danairat Thanabodithammachari
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
Danairat Thanabodithammachari
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
Danairat Thanabodithammachari
 
Setting up Hadoop YARN Clustering
Setting up Hadoop YARN ClusteringSetting up Hadoop YARN Clustering
Setting up Hadoop YARN Clustering
Danairat Thanabodithammachari
 
JEE Programming - 03 Model View Controller
JEE Programming - 03 Model View ControllerJEE Programming - 03 Model View Controller
JEE Programming - 03 Model View Controller
Danairat Thanabodithammachari
 
JEE Programming - 05 JSP
JEE Programming - 05 JSPJEE Programming - 05 JSP
JEE Programming - 05 JSP
Danairat Thanabodithammachari
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
Danairat Thanabodithammachari
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
Danairat Thanabodithammachari
 
JEE Programming - 06 Web Application Deployment
JEE Programming - 06 Web Application DeploymentJEE Programming - 06 Web Application Deployment
JEE Programming - 06 Web Application Deployment
Danairat Thanabodithammachari
 
Thailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AMThailand State Enterprise - Business Architecture and SE-AM
Thailand State Enterprise - Business Architecture and SE-AM
Danairat Thanabodithammachari
 
Agile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 DanairatAgile Organization and Enterprise Architecture v1129 Danairat
Agile Organization and Enterprise Architecture v1129 Danairat
Danairat Thanabodithammachari
 
Enterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 DanairatEnterprise Architecture and Agile Organization Management v1076 Danairat
Enterprise Architecture and Agile Organization Management v1076 Danairat
Danairat Thanabodithammachari
 
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by DanairatDigital Transformation, Enterprise Architecture, Big Data by Danairat
Digital Transformation, Enterprise Architecture, Big Data by Danairat
Danairat Thanabodithammachari
 
Big data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guideBig data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guide
Danairat Thanabodithammachari
 
Big data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guideBig data hadooop analytic and data warehouse comparison guide
Big data hadooop analytic and data warehouse comparison guide
Danairat Thanabodithammachari
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File Processing
Danairat Thanabodithammachari
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
Danairat Thanabodithammachari
 

Recently uploaded (20)

OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right WayMigrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025Top 5 Task Management Software to Boost Productivity in 2025
Top 5 Task Management Software to Boost Productivity in 2025
Orangescrum
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...
Insurance Tech Services
 
Software Testing & it’s types (DevOps)
Software  Testing & it’s  types (DevOps)Software  Testing & it’s  types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 

Java Programming - 07 java networking

  • 1. Module 07 – Java Networking Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446
  • 2. Fundamental Java Programming The Course Outline Module 01 – Introduction to Java Module 02 – Basic Java Programming Module 03 – Control Flow and Exception Handling Module 04 – Object Oriented in Java Module 05 – Java Package and Access Control Module 06 – Java File IO Module 07 – Java Networking Module 08 – Java Threading
  • 3. Module 07 – Java Networking • Basic Networking • Network Port Numbers • Java Socket • Writing Server Socket • Writing Client Socket • Passing Object over Network
  • 4. Basic Networking TCP: The protocol for two applications which are want to communicate to each other reliably, they establish a connection and send data back and forth over that connection. This is analogous to making a telephone call. UDP: The protocol that is not guaranteed between two applications on the network. UDP is not connection-based like TCP. Rather, it sends independent packets of data, called datagrams, from one application to another. Sending datagrams is much like sending a letter through the postal service: The order of delivery is not important and is not guaranteed, and each message is independent of any other.
  • 5. Network Port Numbers IP Address is a unique number of computer network address for both server and client. Ports are identified by a 16-bit number (65536 ports), which TCP and UDP use to deliver the data to the right application. The first 1024 port numbers have been reserved by system root user. The rest port numbers can be use by other system users.
  • 6. Java Socket A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes are used to represent the connection between a client program and a server program. The java.net package provides two classes--Socket and ServerSocket--that implement the client side of the connection and the server side of the connection, respectively.
  • 7. Simple Socket Server package javanetworkingproject; import java.net.*; import java.io.*; public class MyServer { public static void main(String args[]) throws IOException { // Register service on port 1234 ServerSocket s = new ServerSocket(1234); Socket s1= s.accept(); // Wait and accept a connection // Get a communication stream associated with the socket OutputStream s1out = s1.getOutputStream(); DataOutputStream dos = new DataOutputStream (s1out); // Send a string! dos.writeUTF("Hi there สวัสดี"); // Close the connection, but not the server socket dos.close(); s1out.close(); s1.close(); } }
  • 8. Simple Client Server import java.net.*; import java.io.*; public class MyClient { public static void main(String args[]) throws IOException { // Open your connection to a server, at port 1234 Socket s1 = new Socket("127.0.0.1",1234); // Get result from server InputStream s1In = s1.getInputStream(); DataInputStream dis = new DataInputStream(s1In); String st = new String (dis.readUTF()); System.out.println(st); // When done, just close the connection and exit dis.close(); s1In.close(); s1.close(); } } Hi there สวัสดี
  • 9. Object Passing over network import java.io.Serializable; public class Customer implements Serializable{ private String name; private int collectedPoints; public void setName(String name) { this.name = name; } public String getName() { return name; } public void setCollectedPoints(int collectedPoints) { this.collectedPoints = collectedPoints; } public int getCollectedPoints() { return collectedPoints; } }
  • 10. Server Socket Programming with Object Passing package javanetworkingproject2; import java.net.*; import java.io.*; public class MyServer2 { public static void main(String[] args) throws Exception { // Register service on port 1234 ServerSocket s = new ServerSocket(1234); Socket s1 = s.accept(); // Wait and accept a connection // Read input from client ObjectInputStream objInputStream = new ObjectInputStream(s1.getInputStream()); Customer cust1 = (Customer)objInputStream.readObject(); cust1.setCollectedPoints(3000); // Write result to client OutputStream s1out = s1.getOutputStream(); ObjectOutputStream objOutputStream = new ObjectOutputStream(s1out); objOutputStream.writeObject(cust1); // Close the connection, but not the server socket objOutputStream.close(); s1out.close(); objInputStream.close(); s1.close(); } }
  • 11. Client Socket Programming with Object Passing import java.net.*; import java.io.*; public class MyClient2 { public static void main(String[] args) throws Exception { // Open your connection to a server, at port 1234 Socket s1 = new Socket("127.0.0.1", 1234); // Write object to the socket server Customer cust1 = new Customer(); cust1.setName("Somchai"); ObjectOutputStream objOutputStream = new ObjectOutputStream(s1.getOutputStream()); objOutputStream.writeObject(cust1); // Get result from server InputStream s1In = s1.getInputStream(); ObjectInputStream objInputStream = new ObjectInputStream(s1In); Customer custResult = (Customer)objInputStream.readObject(); System.out.println(custResult.getName() + " has " + custResult.getCollectedPoints() + " points"); // When done, just close the connection and exit objInputStream.close(); s1In.close(); objOutputStream.close(); s1.close(); } }
  • 12. URL Reader import java.net.*; import java.io.*; public class URLReader { public static void main(String[] args) throws Exception { URL googleURL = new URL("http://www.google.com/"); BufferedReader in = new BufferedReader( new InputStreamReader( googleURL.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } }
  • 13. Danairat T. Line ID: Danairat FB: Danairat Thanabodithammachari +668-1559-1446 Thank you