SlideShare a Scribd company logo
1 of 10
Networking with Java
Socket programming
Presented by
ganesh kavhar
The Interweb thing Al Gore
invented…
 Internet is a network of networks.
 The Internet is really people communicating.
 Application layers 7, 6 :
 email, HTTP, FTP, Telnet, file 'sharing', streaming
media, VoIP
 remote access: VPN
 Session layer 5: connections. e.g. sockets
 Transport layer 4: TCP, UDP
 Network layer 3: IP, the Internet
 Link layer 2, 1: NICs, device drivers, magic.
Internet traffic
 10% YouTube HTTP
 36% other HTTP
 37% P2P
 17% newsgroups, streaming, gaming, VoIP
 In other words, mostly a waste of bits.
Internet…what's it good for?
 For years there has been a theory that
millions of monkeys typing at random on
millions of typewriters would reproduce the
entire works of Shakespeare…
The Internet has proven this theory to be
untrue. - Anonymous
Socket Programming
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your
floppy disk abort,
then the socket packet pocket has an error to
report!
from A Grandchild's Guide to Using Grandpa's
Computer by Gene Ziegler
Sockets programming
 a client exchanging data with a server
 An Internet socket is composed of the
following:
 Protocol (TCP, UDP, raw IP)
 Local IP address (your computer)
 Local port (your application)
 Remote IP address (another computer)
 Remote port (another application)
Server Sockets in Java
 package java.net
 ServerSocket server =
new ServerSocket(PORT);
// waits for network requests.
 Socket socket = server.accept();
// waits for a connection and returns a socket
 use java.io to exchange data
 InputStream from socket (client)
 OutputStream to socket (client)
Client Sockets in Java
 package java.net
 Socket socket = new Socket ( host, port);
// waits for a connection to host on a port and
returns a socket
 use java.io to exchange data
 InputStream from socket (server)
 OutputStream to socket (server)
 see PortScanner.java
URL and IP addresses
 URL class represents a
Uniform Resource Locator, a pointer to a
"resource" on the World Wide Web.
 see ReadURL.java
 InetAddress class represents an
Internet Protocol (IP) address.
 used to find out who the socket is talking to.
 ServerSocket or Socket can .getInetAddress();
Sockets Programming
see
 EchoServer.java & EchoClient.java
 simple two-way communication
 EchoServerThread.java & EchoClient.java
 multi-threaded server to handle many sets of
two-way communication

More Related Content

What's hot

Inter process communication
Inter process communicationInter process communication
Inter process communication
Pradeep Kumar TS
 
Defcamp 2013 - SSL Ripper
Defcamp 2013 - SSL RipperDefcamp 2013 - SSL Ripper
Defcamp 2013 - SSL Ripper
DefCamp
 
基于 Google protobuf 的 webgame 网络协议设计
基于 Google protobuf 的 webgame 网络协议设计基于 Google protobuf 的 webgame 网络协议设计
基于 Google protobuf 的 webgame 网络协议设计
勇浩 赖
 

What's hot (20)

Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Network programming Using Python
Network programming Using PythonNetwork programming Using Python
Network programming Using Python
 
playaround workshop 2010 - internet of the real things
playaround workshop 2010 - internet of the real thingsplayaround workshop 2010 - internet of the real things
playaround workshop 2010 - internet of the real things
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
 
Basic socket programming
Basic socket programmingBasic socket programming
Basic socket programming
 
Arduino Teaching Program
Arduino Teaching ProgramArduino Teaching Program
Arduino Teaching Program
 
Python networking
Python networkingPython networking
Python networking
 
Introduction To Distributed Erlang
Introduction To Distributed ErlangIntroduction To Distributed Erlang
Introduction To Distributed Erlang
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
Tcp sockets
Tcp socketsTcp sockets
Tcp sockets
 
Lecture10
Lecture10Lecture10
Lecture10
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing Live Streaming with Receiver-based Peer-division Multiplexing
Live Streaming with Receiver-based Peer-division Multiplexing
 
Artillery Duel Network
Artillery Duel NetworkArtillery Duel Network
Artillery Duel Network
 
Network programming using python
Network programming using pythonNetwork programming using python
Network programming using python
 
Java
JavaJava
Java
 
Biopython
BiopythonBiopython
Biopython
 
Defcamp 2013 - SSL Ripper
Defcamp 2013 - SSL RipperDefcamp 2013 - SSL Ripper
Defcamp 2013 - SSL Ripper
 
基于 Google protobuf 的 webgame 网络协议设计
基于 Google protobuf 的 webgame 网络协议设计基于 Google protobuf 的 webgame 网络协议设计
基于 Google protobuf 的 webgame 网络协议设计
 

Similar to Networking with java

Networking
NetworkingNetworking
Networking
Tuan Ngo
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 
Pears
PearsPears
Pears
thips
 
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdfOf the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
anuradhasilks
 

Similar to Networking with java (20)

Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
TCP/IP For Engineers
TCP/IP For EngineersTCP/IP For Engineers
TCP/IP For Engineers
 
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
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
 
Lecture25
Lecture25Lecture25
Lecture25
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
E-business Infrastructure and Security
E-business Infrastructure and SecurityE-business Infrastructure and Security
E-business Infrastructure and Security
 
Pears
PearsPears
Pears
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
Java 1
Java 1Java 1
Java 1
 
Networking in Java
Networking in JavaNetworking in Java
Networking in Java
 
How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...How does the internet work converted General (Your) Affiliate Link: https://w...
How does the internet work converted General (Your) Affiliate Link: https://w...
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Network protocols and Java programming
Network protocols and Java programmingNetwork protocols and Java programming
Network protocols and Java programming
 
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdfOf the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
Of the variedtypes of IPC, sockets arout and awaythe foremostcommon..pdf
 
Networking:) Based on Ethical Hacking And Cyber Security
Networking:) Based on Ethical Hacking And Cyber SecurityNetworking:) Based on Ethical Hacking And Cyber Security
Networking:) Based on Ethical Hacking And Cyber Security
 

More from Savitribai Phule Pune University

More from Savitribai Phule Pune University (10)

Learn c programming
Learn c programmingLearn c programming
Learn c programming
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
Python for data analysis
Python for data analysisPython for data analysis
Python for data analysis
 
Control statements in java programmng
Control statements in java programmngControl statements in java programmng
Control statements in java programmng
 
Search engines by ganesh kavhar
Search engines by ganesh kavharSearch engines by ganesh kavhar
Search engines by ganesh kavhar
 
Python by ganesh kavhar
Python by ganesh kavharPython by ganesh kavhar
Python by ganesh kavhar
 
Machine learning by ganesh kavhar
Machine learning by ganesh kavharMachine learning by ganesh kavhar
Machine learning by ganesh kavhar
 
Android apps
Android appsAndroid apps
Android apps
 
Android apps upload slideshare
Android apps upload slideshareAndroid apps upload slideshare
Android apps upload slideshare
 
Android app upload
Android app uploadAndroid app upload
Android app upload
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 

Networking with java

  • 1. Networking with Java Socket programming Presented by ganesh kavhar
  • 2. The Interweb thing Al Gore invented…  Internet is a network of networks.  The Internet is really people communicating.  Application layers 7, 6 :  email, HTTP, FTP, Telnet, file 'sharing', streaming media, VoIP  remote access: VPN  Session layer 5: connections. e.g. sockets  Transport layer 4: TCP, UDP  Network layer 3: IP, the Internet  Link layer 2, 1: NICs, device drivers, magic.
  • 3. Internet traffic  10% YouTube HTTP  36% other HTTP  37% P2P  17% newsgroups, streaming, gaming, VoIP  In other words, mostly a waste of bits.
  • 4. Internet…what's it good for?  For years there has been a theory that millions of monkeys typing at random on millions of typewriters would reproduce the entire works of Shakespeare… The Internet has proven this theory to be untrue. - Anonymous
  • 5. Socket Programming If a packet hits a pocket on a socket on a port, and the bus is interrupted as a very last resort, and the address of the memory makes your floppy disk abort, then the socket packet pocket has an error to report! from A Grandchild's Guide to Using Grandpa's Computer by Gene Ziegler
  • 6. Sockets programming  a client exchanging data with a server  An Internet socket is composed of the following:  Protocol (TCP, UDP, raw IP)  Local IP address (your computer)  Local port (your application)  Remote IP address (another computer)  Remote port (another application)
  • 7. Server Sockets in Java  package java.net  ServerSocket server = new ServerSocket(PORT); // waits for network requests.  Socket socket = server.accept(); // waits for a connection and returns a socket  use java.io to exchange data  InputStream from socket (client)  OutputStream to socket (client)
  • 8. Client Sockets in Java  package java.net  Socket socket = new Socket ( host, port); // waits for a connection to host on a port and returns a socket  use java.io to exchange data  InputStream from socket (server)  OutputStream to socket (server)  see PortScanner.java
  • 9. URL and IP addresses  URL class represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.  see ReadURL.java  InetAddress class represents an Internet Protocol (IP) address.  used to find out who the socket is talking to.  ServerSocket or Socket can .getInetAddress();
  • 10. Sockets Programming see  EchoServer.java & EchoClient.java  simple two-way communication  EchoServerThread.java & EchoClient.java  multi-threaded server to handle many sets of two-way communication