DOC PREVIEW
UMD CMSC 132 - Networking Support In Java 2

This preview shows page 1-2-17-18-19-36-37 out of 37 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 37 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Networking Support In Java 2OverviewInternet DesignInternetInternet Protocol (IP)User Datagram Protocol (UDP)Transmission Control Protocol (TCP)Slide 8Client / Server ModelClient ProgrammingServer ProgrammingSlide 12Client / Server Model ExamplesNetworking in JavaJava Networking APIJava Networking ClassesInetAddress ClassDatagramPacket ClassSlide 19DatagramPacket MethodsSocket ClassesSocket ClassSocket MethodsServerSocket ClassServerSocket MethodsConnection OrientedDatagramSocket ClassDatagramSocket MethodsPacket OrientedURL ClassURL ConstructorsURL MethodsURL Connection ClassesJava AppletsApplet SandboxSlide 36Network SummaryNetworking Support In Java 2 Fawzi EmadChau-Wen TsengDepartment of Computer ScienceUniversity of Maryland, College ParkOverviewNetworkingBackgroundConceptsNetwork applications Java’s objected-oriented viewJava’s networking API (Application Program Interface)Last lectureThis lectureInternet DesignInternetNetwork layerInternet Protocol (IP)Transport layerUser Datagram Protocol (UDP)Transmission Control Protocol (TCP)Internet Protocol (IP)Packet orientedPackets routed between computersUnreliableUser Datagram Protocol (UDP)Packet oriented Message split into datagrams Send datagrams as packets on network layerUnreliable but fastApplication must deal with lost packetsExamplesPingStreaming multimediaOnline gamesTransmission Control Protocol (TCP)Connection orientedMessage split into datagramsSend datagrams as packets on network layerProvides illusion of reliable connectionExtra messages between sender / recipientResend packets if necessary Ensure all packets eventually arriveStore packets and process in orderTransmission Control Protocol (TCP)Reliable but slowerApplication can treat as reliable connectionDespite unreliability of underlying IP (network)Examplesftp (file transfer)telnet (remote terminal)http (web)Client / Server ModelRelationship between two computer programsClientInitiates communicationRequests servicesServerReceives communicationProvides servicesOther modelsMaster / workerPeer-to-peer (P2P)ClientClientClientServerServerClientClient ProgrammingBasic steps1. Determine server location – IP address & port2. Open network connection to server3. Write data to server (request)4. Read data from server (response)5. Close network connection6. Stop clientServer ProgrammingBasic steps1. Determine server location - port (& IP address)2. Create server to listen for connections3. Open network connection to client4. Read data from client (request)5. Write data to client (response)6. Close network connection to client7. Stop serverServer ProgrammingCan support multiple connections / clientsLoopHandles multiple connections in orderMultithreadingAllows multiple simultaneous connectionsClient / Server Model ExamplesApplication Client ServerWeb Browsing Internet Explorer, Mozilla FirefoxApacheEmail MS Outlook, ThunderbirdPOP, IMAP, SMTP, ExchangeStreaming MusicWindows Media Player, iTunesInternet RadioOnline GamingHalf-Life, Everquest, PartyPokerGame / Realm ServersNetworking in JavaPackagesjava.net  Networkingjava.io  I/O streams & utilitiesjava.rmi  Remote Method Invocationjava.security  Security policiesjava.lang  Threading classesSupport at multiple levelsData transport  Socket classesNetwork services  URL classesUtilities & securityJava Networking APIApplication Program InterfaceSet of routines, protocols, tools For building software applicationsJava networking APIHelps build network applicationsInterfaces to sockets, network resourcesCode implementing useful functionalityIncludes classes forSocketsURLsJava Networking ClassesIP addressesInetAddressPacketsDatagramPacketSocketsSocketServerSocketDatagramSocketURLsURLInetAddress ClassRepresents an IP addressCan convert domain name to IP addressPerforms DNS lookupGetting an InetAddress objectgetLocalHost()getByName(String host)getByAddress(byte[] addr)DatagramPacket ClassEach packet containsInetAddressPort of destinationDataDatagramPacket ClassData in packet represented as byte arrayDatagramPacket MethodsgetAddress() getData()getLength()getPort()setAddress()setData() setLength()setPort()Socket ClassesProvides interface to TCP, UDP socketsSocketTCP client socketsServerSocketTCP server socketsDatagramSocketUDP sockets (server or client)Socket ClassCreates socket for clientConstructor connects toMachine name or IP addressPort numberTransfer data via streamsSimilar to standard Java I/O streamsSocket MethodsgetInputStream() getOutputStream()close()getInetAddress()getPort()getLocalPort()ServerSocket ClassCreate socket on serverConstructor specifies local portServer listens to portUsageBegin waiting after invoking accept()Listen for connection (from client socket)Returns Socket for connectionServerSocket Methodsaccept()close()getInetAddress()getLocalPort()Connection OrientedTCP ProtocolDatagramSocket ClassCreate UDP socketDoes not distinguish server / client socketsConstructor specifies InetAddress, portSet up UPD socket connectionSend / receive DatagramPacketDatagramSocket Methodsclose()getLocalAddress()getLocalPort()receive(DatagramPacket p)send(DatagramPacket p)setSoTimeout(int t)getSoTimeout()Packet OrientedUDP ProtocolURL ClassProvides high-level access to network dataAbstracts the notion of a connectionConstructor opens network connectionTo resource named by URLURL ConstructorsURL( fullURL )URL( "http://www.cs.umd.edu/class/index.html" )URL( baseURL, relativeURL )URL base = new URL("http://www.cs.umd.edu/" );URL class = new URL( base, "/class/index.html " );URL( protocol, baseURL, relativeURL )URL( "http", www.cs.umd.edu, "/class/index.html" )URL( protocol, baseURL, port, relativeURL )URL( "http", www.cs.umd.edu, 80,"/class/index.html" )URL MethodsgetProtocol( )getHost( )getPort( )getFile( )getContent( )openStream()openConnection()URL Connection ClassesHigh level description of network serviceAccess resource named by URLCan define own protocolsExamplesURLConnection  Reads resource HttpURLConnection  Handles web pageJarURLConnection  Manipulates Java ArchivesURLClassLoader  Loads class file into JVMJava AppletsApplets are Java programs Classes downloaded from networkRun in browser on clientApplets have special security restrictionsExecuted in applet sandboxControlled by java.lang.SecurityManagerApplet SandboxPreventsLoading libraries Defining native methodsAccessing local host file systemRunning other programs (Runtime.exec())Listening for connectionsOpening sockets


View Full Document

UMD CMSC 132 - Networking Support In Java 2

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Download Networking Support In Java 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Networking Support In Java 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Networking Support In Java 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?