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ɏ츯c'Q&gduG!a3eίo6r6XvCP3L OghѬctQ5]@lj׹:+{ԽQLu߭+UrF:tOh4?Ir Fy{a" } ^%Y)1>x2nN><t'߹iOUN2qZ%n{yc4=;"??OgWWټi3{E|쉝vo.8q=T?v4Ǭ/-Eȋr}:vbɭ5&wGj.ğc^poO<Ǜq&˕q75ywXBxAEk2 IHuNTgY\=5%鑪GCmhoFr%)U6Wܯi k'^/QtVo~Nn샥ߑߓvAɟ&x:?9G&>s샥{90; }~Ni{"?~L :?>s4gtc'=Cd~÷<</bE#kȶI]{)ؚzkzeE.t)FB׹uWV^y:)kewZcaw)`4iE-GDe2~"ݿy-|!k;ce_k;3:f'&93>~|LEhgŝ?_;zoϥc}㚨߱qt9Dw+~ċ|z6֊OWױpEUcxѢpFWdl)( l/ 0DTimes New Roman@b@bLb0pbpb 0DArial Blackman@b@bLb0pbpb 0" DTahomalackman@b@bLb0pbpb 0"0DMonotype Sorts@b@bLb0pbpb 0@DArialpe Sorts@b@bLb0pbpb 0"PDArial Narrows@b@bLb0pbpb 0"  @n?" dd@  @@``  H v"         !"/X$R$bؙ iԌV g?c $ @8> g4HdHd|b 0tbX pppp@ g4KdKd|b 0tbX p@ pp<4BdBd4v@b ?T+ @Tim Margush, University of AkronOl;ST: Java @Tim Margush, University of Akron&Cup 10: NetworkingSpecial Topics: Javajava.netContains classes related to networking IP Address Uniform Resource Locator (URL) Sockets Server and regular sockets Transmission Protocols TCP/IP UDP Z'2 '2  IP Addresses130.101.5.4 dotted quad format kira.cc.uakron.edu domain name format The following ststic methods return a new InetAddress object InetAddress.getByName(String) InetAddress.getLocalHost()l =9 =9!     InetAddress Class getAllByName(String) returns an array of InetAddress objects UnknownHostException getHostAddress() returns the IP address as a String in dotted quad format getHostName() returns the domain namel=9=9H  #< Uniform Resource LocatorProtocol HTTP, FTP, GOPHER, FILE, NEWS Host dotted quad or domain name format Port 0-1024 are more or less reserved File A String representing the resource "!# "!# URL ClassURL(String, String, int, String) URL(String, String, String) port number is implied by the protocol URL(String) "http://www.cs.uakron.edu/index.html" URL(URL, String) creates a relative URL, parsing the String within the context of the given URLl=' &O=' &OPem$Establishing a Connection with a URLURLConnection openConnection() Instantiates a connection Object for the the URL connection settings are manipulated before the actual connection is established Method connect() establishes the connection using the appropriate protocol handler and settings of the URLConnection objectH1P|1P|6 Using a Connection with a URLObject getContent() InputStream getInputStream() A URL's openStream() method is a shortcut for the two-step process: URL.openConnection().getInputStream() OutputStream getOutputStream() String getVariousHeaderInfo()H1j=1j)  6 SocketsStream - supports active communications between two computers a route is established data is streamed in packets receipt is verified before the next packet is sent(>f>f Datagram - supports connectionless communication (UDP) message is broken into packets and sent to a router packets bounce between routers until they arrive at their destination packets must be reassembled to retrieve the message(77$* Client SocketsSocket cs = new Socket(addr, port); app<->|client|<------>|server|<->app InputSream and OutputStream objects are constructed from the socket to support transfer of data The remote socket is usually created by a server to form the other end of the connection6$%$%P .   Boilerplate Server@ServerSocket server = new ServerSocket(1234); Socket sock = server.accept(); Thread is blocked at this statement until a connection request occurs which causes a new Socket to be created to form the other end of the communications stream InputStream in = sock.getInputStream(); OutputStream out = sock.getOutputStream();4AMSl       Datagram Client/Server The server and client simply create a Datagram socket Datagram socket = new DatagramSocket(port); The system will assign a port number if you do not request one The server should specify a port number so the client knows where to send the datagramsJb5+P&   DatagramPacketnew DatagramPacket(msg, len, addr, port); This creates a packet to be sent msg is a byte array len is the size of the msg (in bytes) addr is the InetAddress the package is going to port is the port number on the receiving end0K*!*  E Sending and Receiving Datagrams socket.send(aPacket); Packet is sent out on the Internet and is routed toward the destination socket.receive(anotherPacket); This is a blocking statement that waits for a datagram to be received. anotherPacket was created with no address info, just a byte array and lengthHHHP Z 1 ?"Decoding a Received DatagramPacketPpack.getAddress(); pack.getPort(); pack.getLength() pack.getData(); set methodsP   /        ` ^WN̙f` ^WNff3` 999MMM` ^WNf` ff33` ff33` ^WN̙f>?" dd@(?zdd@ y x@" `  n?" dd@   @@``@n?" dd@  @@``PR   @ ` ` p>> ^V(    C XA@C:\WINDOWS\DESKTOP\JavaBack.jpg  s *dv 0` v T Click to edit Master title style! !   c $v @ v RClick to edit Master text styles Second level Third level Fourth level Fifth level!     S  s *$v Tt v E* 2  s *v Tt  v G*(2  s *v T@t v J10-*(2Z  B޽h))? ? ^WNff3 Javaxx.potd   ` ( &`    C XA@C:\WINDOWS\DESKTOP\JavaBack.jpg  s *$ @@  T Click to edit Master title style! !  c $ @   W#Click to edit Master subtitle style$ $  s *D T  E* 2^WN  s * T   G*(2^WN  s * T@  G*(2^WNZ  B޽h))? ? ^WNff3 0 @.(    0ԉ P    Y*   04     [* d  c $ ?    0  @  RClick to edit Master text styles Second level Third level Fourth level Fifth level!     S  6 `P   Y*   6T `   [* H  0޽h ? ̙33 04(      0T P    =*   0     ?*   6 `P   =*   6t `   ?* H  0޽h ? ̙33 xp( K l  C d PP   r  S  ` p    0$0 pj VDr. Tim Margush Department of Mathematics and Computer Science The University of AkronW(2WH  0޽h ? ^WNff3  (  l  C 0`   l  C D@  H  0޽h ? ^WNff3  (  l  C d0`   l  C @  H  0޽h ? ^WNff3  (  l  C d0`   l  C ă@  H  0޽h ? ^WNff3  (  l  C 0`   l  C @  H  0޽h ? ^WNff3  (  l  C Ć0`   l  C $@  H  0޽h ? ^WNff3  0(  l  C 0`   l  C d@  H  0޽h ? ^WNff3  P(  l  C D0`   l  C @  H  0޽h ? ^WNff3R  p(  l  C Č0`   r  S $   l  C 8 @  H  0޽h ? ^WNff3   (  l  C D0`   l  C @  H  0޽h ? ^WNff3   (  l  C Dp0`   l  C p@  H  0޽h ? ^WNff3   ( h l  C $r0`   l  C r@  H  0޽h ? ^WNff3   (  l  C $u0`   l  C u@  H  0޽h ? ^WNff3   (  l  C w0`   l  C $x@  H  0޽h ? ^WNff3   (  l  C D&v0`  v l  C &v@ v H  0޽h ? ^WNff3 0 x( X R  3    ~  C  @    H  0޽h ? ̙33\ 0 (  R  3      C  @   rIP Addresses are used to identify machines connected on a network. This identification occurs at the network layer (IP). The hardware and associated drivers provide the underlying support for this protocol (physical layer). Information is transferred from system to system using come communications protocol. Java supports two common protocols, TCP and UDP. TCP is a connection based protocol, while UDP is connectionless and functions by sending messages in independent packets. Sockets provide the basic interface for data transfer at this level. URL's provide a straightforward method of identifying resources on a network.,a,H  0޽h ? ̙33 0 F>(  R  3    D  C  @   Every computer connected to the Internet has at least one IP address. This is a four part number. Each part is a value in the range 0-255. Computers may also have host or domain names. These are string representations of the actual IP address. Many host names can represent the same IP address. A Domain Name Server (DNS) provides the lookup facility to translate between the dotted quad format and the domain name representation.=oH  0޽h ? ̙33 0 k(   R  3      C 䄖 @   yYou must use one of the static methods, getByName, getAllByName, or getLocalHost, to create an InetAddress object. The argument is a String representing the IP address in dotted quad format, or as a domain name. These methods can throw an UnknownHostException. getLocalHost requires no argument. getByName with an argument of NULL will return the local host. Once constructed, the object can report the host's name or IP address. Other methods exist which may be useful.(      H  0޽h ? ̙33 0 5(   R  3      C d @   C/URL's consist of four parts. Although the last part is called the File, it may refer to any resource the host system is able to deliver. In some cases, an anchor (ref or reference) is added to the end of the File part (after the # symbol) to specify a part of the resource rather than the entire object.H  0޽h ? ̙33 0 H@ (  R  3    F  C  @   2There are four ways to construct a new URL object. The last is used to construct one from a relative spec. For example, if the URL object refers to "http://www.cs.uakron.edu/~margush" and the String is "286Java/index.html", then the new URL would be "http://www.cs.uakron.edu/~margush/286Java/index.html"RH  0޽h ? ̙33$ 0 @t(  R  3      C 䊖 @   :The URLConnection class is a superclass of all objects representing a communications link between the application and a URL. Once one of these objects is created, various methods are used to determine and set communications parameters. The connect() method is then used to establish the actual communications link., H  0޽h ? ̙33N 0 `(  R  3       C d @   dOnce a connection is established, a data stream my be established or information about the resource may be obtained. There are methods to determine the content type and length, date created, modified, and epired, or any other information available in the header fields of the URL. The getContent method returns an Object of the type represented by the URL.,J =H  0޽h ? ̙33 0 me(  R  3    k  C 䍖 @   Sockets provide basic communications between two applications (perhaps on different computers). Stream oriented sockets are the most reliable, but tend to be slower. Datagram sockets are faster, but less reliable. 'H  0޽h ? ̙33  0 :( ,\ R  3      C  @   HThere are various constructors that may be used to obtain a new socket object. Each socket must be bound to a port on the local and remote machines (each may be different). Usually a ServerSocket running on the remote machine will accept the request for a connection and create a new socket bound to a port to handle the other end of the communication. The ServerSocket listens for requests an a prearranged port number; this is the port specified in the ServerSocket and Socket constructors. >  V H  0޽h ? ̙33  0 {s (  R  3    y  C q @   The ServerSocket runs on the host machine, listening for requests on the specified port. The ServerSocket allows a timeout period to be specified that will throw an exception if no connection is requested within the timeout period. The constructor also allows the programmer to specify the backlog queue length (default is 50) which is the number of connection requests on the port that will be queued for the accept method to process. When the accept method succeeds, a new socket is created to form the server side of the communications. This socket communicates through another port, freeing the server to listen for new requests on the server port. Usually a new Thread is created to handle the socket communications., L hH  0޽h ? ̙33  0 U( TL R  3    v  C t @   cThere is no need for a special SocketServer class when using Datagrams as no fixed connection will be established. Instead, Datagrams are sent to a specific port on a machine. If a DatagramSocket is bound to the port, it may receive those packets.P  5 /4H  0޽h ? ̙33`  0   ( pt  R   3       C dw @   RCreating a DatagramPacket for transmission through a DatagramSocket requires an array of bytes, the length of the message, and the Internet address and port number where the message is to be delivered. Only the first len bytes of the byte array are copied into the packet. Normally you would copy all of the array into the DatagramPacket.P fH   0޽h ? ̙33  0 ia ( , R  3    g  C y @   Once a packet is sent, the actual route is up to the routers it passes through on the Internet. If it eventually arrives at the specified InetAddress, and a DatagramSocket is bound to the specified port, and has issued a receive() method, the packet will be received into the waiting Datagram packet. You must supply a byte array large enough to hold any received Datagram, otherwise a message may be truncated.P p G(H  0޽h ? ̙33 0 P(( 2 R  3      C 4 @   6If you call the getAddress() and getPort() methods of a received DatagramPacket, you can learn the InetAddress and port where the Datagram originated. Before a Datagram is sent, these methods reveal the destination address. Data is retrieved via the getData() method. This returns an array of bytes. The length of the received method is also available. There is a set version of each of these methods.     RH  0޽h ? ̙33r`9>)3B V`Eb|G\Ifj?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijlmnopqrstuvwxyz{|}~Root EntrydO)Picturesg?Current UserSummaryInformation(kRPowerPoint Document( fDocumentSummaryInformation8x@BD)Root EntrydO)m~Picturesg?Current UserMSummaryInformation(kR'_BUniversity UserUniversity User