SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
JAVA UDP Sockets
JAVA - Internet Addresses
 java.net.InetAddress class

 You get an address by using static methods:
 Create InetAddress object representing the local machine
  InetAddress myAddress = InetAddress.getLocalHost();

 Create InetAddress object representing some remote machine
  InetAddress ad = InetAddress.getByName(hostname);
JAVA - Printing Internet Addresses

 You get information from an InetAddress
 by using methods:

 ad.getHostName();
 ad.getHostAddress();
JAVA - The InetAddress Class
 Handles Internet addresses both as host names and as IP addresses
 Static Method getByName returns the IP address of a specified host name as
 an InetAddress object
 Methods for address/name conversion:
  public static InetAddress getByName(String host) throws
      UnknownHostException
  public static InetAddress[] getAllByName(String host) throws
      UnknownHostException
  public static InetAddress getLocalHost() throws UnknownHostException

  public boolean isMulticastAddress()
  public String getHostName()
  public byte[] getAddress()
  public String getHostAddress()
  public int hashCode()
  public boolean equals(Object obj)
  public String toString()
import java.net.*;
import java.io.*;

public class IPFinder
{
          public static void main(String[] args) throws IOException
          {
                    String host;
                    BufferedReader input =
                      new BufferedReader(
                              new InputStreamReader(System.in));

                   System.out.print("nnEnter host name: ");
                   host = input.readLine();
                   try
                   {
                             InetAddress address = InetAddress.getByName(host);
                   System.out.println("IP address: " + address.toString());
                   }
          catch (UnknownHostException e)
          {
                             System.out.println("Could not find " + host);
                   }
          }
}
Retrieving the address of the local machine
import java.net.*;

public class MyLocalIPAddress
{
   public static void main(String[] args)
    {
        try
        {
             InetAddress address = InetAddress.getLocalHost();
             System.out.println (address);
        }
        catch (UnknownHostException e)
        {
             System.out.println("Could not find local address!");
        }
     }
}
The UDP classes
2 classes:
    java.net.DatagramSocket class
        is a connection to a port that does the sending and receiving. A
        DatagramSocket can send to multiple, different addresses.The address
        to which data goes is stored in the packet, not in the socket.
        public DatagramSocket() throws SocketException
        public DatagramSocket(int port) throws SocketException
        public DatagramSocket(int port, InetAddress laddr) throws
        SocketException
    java.net.DatagramPacket class
         is a wrapper for an array of bytes from which data will be sent or into
        which data will be received. It also contains the address and port to
        which the packet will be sent.
        public DatagramPacket(byte[] data, int length)
        public DatagramPacket(byte[] data, int length, InetAddress host, int
        port)
Datagram Sockets
SERVER:
1. Create a DatagramSocket object
   DatagramSocket dgramSocket =
                new DatagramSocket(1234);
2. Create a buffer for incoming datagrams
   byte[] buffer = new byte[256];
3. Create a DatagramPacket object for the incoming datagram
   DatagramPacket inPacket =
                new DatagramPacket(buffer, buffer.length);
4. Accept an incoming datagram
   dgramSocket.receive(inPacket)
Datagram Sockets
SERVER:
5. Accept the sender’s address and port from the packet
   InetAddress clientAddress = inPacket.getAddress();
   int clientPort = inPacket.getPort();
6. Retrieve the data from the buffer
   string message =
     new String(inPacket.getData(), 0, inPacket.getLength());
7. Create the response datagram
   DatagramPacket outPacket =
                new DatagramPacket(
                                response.getBytes(), response.length(),
                                clientAddress, clientPort);
8. Send the response datagram
   dgramSocket.send(outPacket)
9. Close the DatagramSocket: dgram.close();
Datagram Sockets
CLIENT:
1.  Create a DatagramSocket object
    DatagramSocket dgramSocket = new DatagramSocket;
2.  Create the outgoing datagram
    DatagramPacket outPacket = new DatagramPacket(
                                           message.getBytes(),
                                           message.length(),
                                           host, port);
3.  Send the datagram message
    dgramSocket.send(outPacket)
4.  Create a buffer for incoming datagrams
     byte[] buffer = new byte[256];
Datagram Sockets
CLIENT:
5.  Create a DatagramPacket object for the incoming datagram
    DatagramPacket inPacket =
               new DatagramPacket(buffer, buffer.length);
6.  Accept an incoming datagram
    dgramSocket.receive(inPacket)
7.  Retrieve the data from the buffer
    string response = new String(inPacket.getData(), 0,
                                     inPacket.getLength());
8.  Close the DatagramSocket:
        dgram.close();
Sending UDP packets

 When you receive a packet, the IP and
 port number of the sender are set in the
 DatagramPacket.

 You can use the same packet to reply, by
 overwriting the data, using the method:
   packet.setData(newbuffer);
Non-blocking I/O receiving UDP
packets
 You can set a time-out in milliseconds to
 determine how long a read operation
 blocks, before throwing an exception.
   socket.setSoTimeout(duration);
 If the duration given in milliseconds is
 exceeded, an exception is thrown:
   java.io.InterruptedException
References
 Cisco Networking Academy Program (CCNA), Cisco Press.

 CSCI-5273 : Computer Networks, Dirk Grunwald, University of Colorado-Boulder

 CSCI-4220: Network Programming, Dave Hollinger, Rensselaer Polytechnic Institute.

 TCP/IP Illustrated, Volume 1, Stevens.

 Java Network Programming and Distributed Computing, Reilly & Reilly.

 Computer Networks: A Systems Approach, Peterson & Davie.

 http://www.firewall.cx

 http://www.javasoft.com

Weitere ähnliche Inhalte

Was ist angesagt?

Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
Jafka guide
Jafka guideJafka guide
Jafka guideAdy Liu
 
Writing Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeepWriting Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeepSylvain Hallé
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with BlocksJeff Kelley
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEkim.mens
 
The Ring programming language version 1.5.2 book - Part 39 of 181
The Ring programming language version 1.5.2 book - Part 39 of 181The Ring programming language version 1.5.2 book - Part 39 of 181
The Ring programming language version 1.5.2 book - Part 39 of 181Mahmoud Samir Fayed
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019GOG.com dev team
 
The Ring programming language version 1.5.3 book - Part 85 of 184
The Ring programming language version 1.5.3 book - Part 85 of 184The Ring programming language version 1.5.3 book - Part 85 of 184
The Ring programming language version 1.5.3 book - Part 85 of 184Mahmoud Samir Fayed
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GParsPaul King
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)Gagan Agrawal
 

Was ist angesagt? (19)

Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
 
Jafka guide
Jafka guideJafka guide
Jafka guide
 
Writing Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeepWriting Domain-Specific Languages for BeepBeep
Writing Domain-Specific Languages for BeepBeep
 
Ac2
Ac2Ac2
Ac2
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
 
ADO.NETObjects
ADO.NETObjectsADO.NETObjects
ADO.NETObjects
 
Rsa
RsaRsa
Rsa
 
分散式系統
分散式系統分散式系統
分散式系統
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVE
 
The Ring programming language version 1.5.2 book - Part 39 of 181
The Ring programming language version 1.5.2 book - Part 39 of 181The Ring programming language version 1.5.2 book - Part 39 of 181
The Ring programming language version 1.5.2 book - Part 39 of 181
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
 
Php sql-android
Php sql-androidPhp sql-android
Php sql-android
 
Hadoop Puzzlers
Hadoop PuzzlersHadoop Puzzlers
Hadoop Puzzlers
 
The Ring programming language version 1.5.3 book - Part 85 of 184
The Ring programming language version 1.5.3 book - Part 85 of 184The Ring programming language version 1.5.3 book - Part 85 of 184
The Ring programming language version 1.5.3 book - Part 85 of 184
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GPars
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)
 

Andere mochten auch

Presentación1
Presentación1Presentación1
Presentación1jbprog
 
журнал клёпа
журнал клёпажурнал клёпа
журнал клёпаklepa.ru
 
Ppt -optimal_healthusa
Ppt  -optimal_healthusaPpt  -optimal_healthusa
Ppt -optimal_healthusaDyna Smith
 
Exercise pada pasien stemi
Exercise pada pasien stemiExercise pada pasien stemi
Exercise pada pasien stemiAnissa Cindy
 
Presentation constructing an information panel
Presentation   constructing an information panelPresentation   constructing an information panel
Presentation constructing an information paneldoogstone
 
Optimal health products
Optimal health productsOptimal health products
Optimal health productsDyna Smith
 
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)vantinhkhuc
 
Mutual Funds - 2013 Gold Monitor Award Winners
Mutual Funds - 2013 Gold Monitor Award WinnersMutual Funds - 2013 Gold Monitor Award Winners
Mutual Funds - 2013 Gold Monitor Award WinnersCorporate Insight
 
Exam preparation tips
Exam preparation tipsExam preparation tips
Exam preparation tipsSarwan Singh
 
Hokkaido.pm.casual #03 slide
Hokkaido.pm.casual #03 slideHokkaido.pm.casual #03 slide
Hokkaido.pm.casual #03 slideTohru Shinohara
 
Barzykin Alexandre
Barzykin AlexandreBarzykin Alexandre
Barzykin Alexandreklepa.ru
 
Resultater fra omnichannel surveyen
Resultater fra omnichannel surveyenResultater fra omnichannel surveyen
Resultater fra omnichannel surveyenRasmus Houlind
 
Annuity and Life Insurance Product Update - Q1 2015
Annuity and Life Insurance Product Update - Q1 2015Annuity and Life Insurance Product Update - Q1 2015
Annuity and Life Insurance Product Update - Q1 2015Corporate Insight
 
Новости недвижимости майами май 2016
Новости недвижимости майами май 2016 Новости недвижимости майами май 2016
Новости недвижимости майами май 2016 The Reznik Group
 

Andere mochten auch (17)

Presentación1
Presentación1Presentación1
Presentación1
 
журнал клёпа
журнал клёпажурнал клёпа
журнал клёпа
 
Vih
VihVih
Vih
 
Ppt -optimal_healthusa
Ppt  -optimal_healthusaPpt  -optimal_healthusa
Ppt -optimal_healthusa
 
Exercise pada pasien stemi
Exercise pada pasien stemiExercise pada pasien stemi
Exercise pada pasien stemi
 
Presentation constructing an information panel
Presentation   constructing an information panelPresentation   constructing an information panel
Presentation constructing an information panel
 
Optimal health products
Optimal health productsOptimal health products
Optimal health products
 
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)
48 nguyen tac chu chot cua quyen luc (robert greene & joost elffers)
 
Mutual Funds - 2013 Gold Monitor Award Winners
Mutual Funds - 2013 Gold Monitor Award WinnersMutual Funds - 2013 Gold Monitor Award Winners
Mutual Funds - 2013 Gold Monitor Award Winners
 
Exam preparation tips
Exam preparation tipsExam preparation tips
Exam preparation tips
 
Shokovy
ShokovyShokovy
Shokovy
 
Tradicii
TradiciiTradicii
Tradicii
 
Hokkaido.pm.casual #03 slide
Hokkaido.pm.casual #03 slideHokkaido.pm.casual #03 slide
Hokkaido.pm.casual #03 slide
 
Barzykin Alexandre
Barzykin AlexandreBarzykin Alexandre
Barzykin Alexandre
 
Resultater fra omnichannel surveyen
Resultater fra omnichannel surveyenResultater fra omnichannel surveyen
Resultater fra omnichannel surveyen
 
Annuity and Life Insurance Product Update - Q1 2015
Annuity and Life Insurance Product Update - Q1 2015Annuity and Life Insurance Product Update - Q1 2015
Annuity and Life Insurance Product Update - Q1 2015
 
Новости недвижимости майами май 2016
Новости недвижимости майами май 2016 Новости недвижимости майами май 2016
Новости недвижимости майами май 2016
 

Ähnlich wie Lecture6

nw-lab_dns-server.pdf
nw-lab_dns-server.pdfnw-lab_dns-server.pdf
nw-lab_dns-server.pdfJayaprasanna4
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programmingashok hirpara
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket ProgrammingVipin Yadav
 
Lab manual cn-2012-13
Lab manual cn-2012-13Lab manual cn-2012-13
Lab manual cn-2012-13Sasi Kala
 
Chapter 4 slides
Chapter 4 slidesChapter 4 slides
Chapter 4 slideslara_ays
 
Easy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client SocketsEasy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client Socketsbabak danyal
 
Distributed systems
Distributed systemsDistributed systems
Distributed systemsSonali Parab
 
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 programgovindjha339843
 
CHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptxCHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptxDhrumilSheth3
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsYakov Fain
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programmingphanleson
 

Ähnlich wie Lecture6 (20)

nw-lab_dns-server.pdf
nw-lab_dns-server.pdfnw-lab_dns-server.pdf
nw-lab_dns-server.pdf
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programming
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
Lab manual cn-2012-13
Lab manual cn-2012-13Lab manual cn-2012-13
Lab manual cn-2012-13
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
java sockets
 java sockets java sockets
java sockets
 
#2 (UDP)
#2 (UDP)#2 (UDP)
#2 (UDP)
 
Java socket presentation
Java socket presentation Java socket presentation
Java socket presentation
 
Chapter 4 slides
Chapter 4 slidesChapter 4 slides
Chapter 4 slides
 
Easy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client SocketsEasy Steps to implement UDP Server and Client Sockets
Easy Steps to implement UDP Server and Client Sockets
 
Distributed systems
Distributed systemsDistributed systems
Distributed systems
 
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
 
CHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptxCHAPTER - 3 - JAVA NETWORKING.pptx
CHAPTER - 3 - JAVA NETWORKING.pptx
 
Network programming1
Network programming1Network programming1
Network programming1
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Ipc
IpcIpc
Ipc
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
 

Mehr von vantinhkhuc (20)

Url programming
Url programmingUrl programming
Url programming
 
Servlets intro
Servlets introServlets intro
Servlets intro
 
Servlet sessions
Servlet sessionsServlet sessions
Servlet sessions
 
Security overview
Security overviewSecurity overview
Security overview
 
Rmi
RmiRmi
Rmi
 
Md5
Md5Md5
Md5
 
Lecture17
Lecture17Lecture17
Lecture17
 
Lecture11 b
Lecture11 bLecture11 b
Lecture11 b
 
Lecture10
Lecture10Lecture10
Lecture10
 
Lecture9
Lecture9Lecture9
Lecture9
 
Jsse
JsseJsse
Jsse
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Jsp examples
Jsp examplesJsp examples
Jsp examples
 
Jpa
JpaJpa
Jpa
 
Ejb examples
Ejb examplesEjb examples
Ejb examples
 
Corba
CorbaCorba
Corba
 
Ajax
AjaxAjax
Ajax
 
Ejb intro
Ejb introEjb intro
Ejb intro
 
Chc6b0c6a1ng 12
Chc6b0c6a1ng 12Chc6b0c6a1ng 12
Chc6b0c6a1ng 12
 
Ch06
Ch06Ch06
Ch06
 

Lecture6

  • 2. JAVA - Internet Addresses java.net.InetAddress class You get an address by using static methods: Create InetAddress object representing the local machine InetAddress myAddress = InetAddress.getLocalHost(); Create InetAddress object representing some remote machine InetAddress ad = InetAddress.getByName(hostname);
  • 3. JAVA - Printing Internet Addresses You get information from an InetAddress by using methods: ad.getHostName(); ad.getHostAddress();
  • 4. JAVA - The InetAddress Class Handles Internet addresses both as host names and as IP addresses Static Method getByName returns the IP address of a specified host name as an InetAddress object Methods for address/name conversion: public static InetAddress getByName(String host) throws UnknownHostException public static InetAddress[] getAllByName(String host) throws UnknownHostException public static InetAddress getLocalHost() throws UnknownHostException public boolean isMulticastAddress() public String getHostName() public byte[] getAddress() public String getHostAddress() public int hashCode() public boolean equals(Object obj) public String toString()
  • 5. import java.net.*; import java.io.*; public class IPFinder { public static void main(String[] args) throws IOException { String host; BufferedReader input = new BufferedReader( new InputStreamReader(System.in)); System.out.print("nnEnter host name: "); host = input.readLine(); try { InetAddress address = InetAddress.getByName(host); System.out.println("IP address: " + address.toString()); } catch (UnknownHostException e) { System.out.println("Could not find " + host); } } }
  • 6. Retrieving the address of the local machine import java.net.*; public class MyLocalIPAddress { public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); System.out.println (address); } catch (UnknownHostException e) { System.out.println("Could not find local address!"); } } }
  • 7. The UDP classes 2 classes: java.net.DatagramSocket class is a connection to a port that does the sending and receiving. A DatagramSocket can send to multiple, different addresses.The address to which data goes is stored in the packet, not in the socket. public DatagramSocket() throws SocketException public DatagramSocket(int port) throws SocketException public DatagramSocket(int port, InetAddress laddr) throws SocketException java.net.DatagramPacket class is a wrapper for an array of bytes from which data will be sent or into which data will be received. It also contains the address and port to which the packet will be sent. public DatagramPacket(byte[] data, int length) public DatagramPacket(byte[] data, int length, InetAddress host, int port)
  • 8. Datagram Sockets SERVER: 1. Create a DatagramSocket object DatagramSocket dgramSocket = new DatagramSocket(1234); 2. Create a buffer for incoming datagrams byte[] buffer = new byte[256]; 3. Create a DatagramPacket object for the incoming datagram DatagramPacket inPacket = new DatagramPacket(buffer, buffer.length); 4. Accept an incoming datagram dgramSocket.receive(inPacket)
  • 9. Datagram Sockets SERVER: 5. Accept the sender’s address and port from the packet InetAddress clientAddress = inPacket.getAddress(); int clientPort = inPacket.getPort(); 6. Retrieve the data from the buffer string message = new String(inPacket.getData(), 0, inPacket.getLength()); 7. Create the response datagram DatagramPacket outPacket = new DatagramPacket( response.getBytes(), response.length(), clientAddress, clientPort); 8. Send the response datagram dgramSocket.send(outPacket) 9. Close the DatagramSocket: dgram.close();
  • 10. Datagram Sockets CLIENT: 1. Create a DatagramSocket object DatagramSocket dgramSocket = new DatagramSocket; 2. Create the outgoing datagram DatagramPacket outPacket = new DatagramPacket( message.getBytes(), message.length(), host, port); 3. Send the datagram message dgramSocket.send(outPacket) 4. Create a buffer for incoming datagrams byte[] buffer = new byte[256];
  • 11. Datagram Sockets CLIENT: 5. Create a DatagramPacket object for the incoming datagram DatagramPacket inPacket = new DatagramPacket(buffer, buffer.length); 6. Accept an incoming datagram dgramSocket.receive(inPacket) 7. Retrieve the data from the buffer string response = new String(inPacket.getData(), 0, inPacket.getLength()); 8. Close the DatagramSocket: dgram.close();
  • 12. Sending UDP packets When you receive a packet, the IP and port number of the sender are set in the DatagramPacket. You can use the same packet to reply, by overwriting the data, using the method: packet.setData(newbuffer);
  • 13. Non-blocking I/O receiving UDP packets You can set a time-out in milliseconds to determine how long a read operation blocks, before throwing an exception. socket.setSoTimeout(duration); If the duration given in milliseconds is exceeded, an exception is thrown: java.io.InterruptedException
  • 14. References Cisco Networking Academy Program (CCNA), Cisco Press. CSCI-5273 : Computer Networks, Dirk Grunwald, University of Colorado-Boulder CSCI-4220: Network Programming, Dave Hollinger, Rensselaer Polytechnic Institute. TCP/IP Illustrated, Volume 1, Stevens. Java Network Programming and Distributed Computing, Reilly & Reilly. Computer Networks: A Systems Approach, Peterson & Davie. http://www.firewall.cx http://www.javasoft.com