欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > PPT文档下载  

    分布式计算原理与应用(DistributedComputing)第四章ppt课件.ppt

    • 资源ID:4000481       资源大小:255KB        全文页数:43页
    • 资源格式: PPT        下载积分:16金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要16金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    分布式计算原理与应用(DistributedComputing)第四章ppt课件.ppt

    3/31/2023,Distributed Computing,M.L.Liu,1,The Socket API,Mei-Ling Liu,3/31/2023,Distributed Computing,M.L.Liu,2,Introduction,The socket API is an Interprocessing Communication(IPC)programming interface originally provided as part of the Berkeley UNIX operating system.It has been ported to all modern operating systems,including Sun Solaris and Windows systems.It is a de facto standard for programming IPC,and is the basis of more sophisticated IPC interface such as remote procedure call and remote method invocation.,3/31/2023,Distributed Computing,M.L.Liu,3,The conceptual model of the socket API,3/31/2023,Distributed Computing,M.L.Liu,4,The socket API,A socket API provides a programming construct termed a socket.A process wishing to communicate with another process must create an instance,or instantiate,such a construct The two processes then issues operations provided by the API to send and receive data.,3/31/2023,Distributed Computing,M.L.Liu,5,Connection-oriented&connectionless datagram socket,A socket programming construct can make use of either the UDP or TCP protocol.Sockets that use UDP for transport are known as datagram sockets,while sockets that use TCP are termed stream sockets.Because of its relative simplicity,we will first look at datagram sockets,returning to stream sockets after we have introduced the client-server model in Chapter 5.,3/31/2023,Distributed Computing,M.L.Liu,6,Connection-oriented&connectionless datagram socket,Datagram sockets can support both connectionless and connection-oriented communication at the application layer.This is so because even though datagrams are sent or received without the notion of connections at the transport layer,the runtime support of the socket API can create and maintain logical connections for datagrams exchanged between two processes,as you will see in the next section.(The runtime support of an API is a set of software that is bound to the program during execution in support of the API.),3/31/2023,Distributed Computing,M.L.Liu,7,Connection-oriented&connectionless datagram socket,3/31/2023,Distributed Computing,M.L.Liu,8,The Java Datagram Socket API,In Java,two classes are provided for the datagram socket API:the DatagramSocket class for the sockets.the DatagramPacket class for the datagram exchanged.A process wishing to send or receive data using this API must instantiate a DatagramSocket object,or a socket in short.Each socket is said to be bound to a UDP port of the machine local to the process,3/31/2023,Distributed Computing,M.L.Liu,9,The Java Datagram Socket API,To send a datagram to another process,a process:creates an object that represents the datagram itself.This object can be created by instantiating a DatagramPacket object which carries(i)the payload data as a reference to a byte array,and(ii)the destination address(the host ID and port number to which the receivers socket is bound.issues a call to a send method in the DatagramSocket object,specifying a reference to the DatagramPacket object as an argument,3/31/2023,Distributed Computing,M.L.Liu,10,The Java Datagram Socket API,In the receiving process,a DatagramSocket object must also be instantiated and bound to a local port,the port number must agree with that specified in the datagram packet of the sender.To receive datagrams sent to the socket,the process creates a datagramPacket object which references a byte array and calls a receive method in its DatagramSocket object,specifying as argument a reference to the DatagramPacket object.,3/31/2023,Distributed Computing,M.L.Liu,11,The Data Structures in the sender and receiver programs,3/31/2023,Distributed Computing,M.L.Liu,12,The program flow in the sender and receiver programs,3/31/2023,Distributed Computing,M.L.Liu,13,Event synchronization with the connectionlss datagram socketsAPI,3/31/2023,Distributed Computing,M.L.Liu,14,Setting timeout,To avoid indefinite blocking,a timeout can be set with a socket object:void setSoTimeout(inttimeout)Set a timeout for the blocking receive from this socket,in milliseconds.Once set,the timeout will be in effect for all blocking operations.,3/31/2023,Distributed Computing,M.L.Liu,15,Key Methods and Constructors,3/31/2023,Distributed Computing,M.L.Liu,16,The coding,3/31/2023,Distributed Computing,M.L.Liu,17,Connectionless sockets,With connectionless sockets,it is possible for multiple processes to simultaneously send datagrams to the same socket established by a receiving process,in which case the order of the arrival of these messages will be unpredictable,in accordance with the UDP protocol,3/31/2023,Distributed Computing,M.L.Liu,18,Code samples,Example1Sender.java,ExampleReceiver.javaMyDatagramSocket.java,Example2SenderReceiver.java,Example2ReceiverSender.java,3/31/2023,Distributed Computing,M.L.Liu,19,Connection-oriented datagram socket API,It is uncommon to employ datagram sockets for connection-oriented communication;the connection provided by this API is rudimentary and typically insufficient for applications that require a true connection.Stream-mode sockets,which will be introduced later,are more typical and more appropriate for connection-oriented communication.,3/31/2023,Distributed Computing,M.L.Liu,20,Methods calls for connection-oriented datagram socket,A connection is made for a socket with a remote socket.Once a socket is connected,it can only exchange data with the remote socket.If a datagram specifying another address is sent usingthe socket,an IllegalArgumentException will occur.If a datagram from another socket is sent to this socket,The data will be ignored.,3/31/2023,Distributed Computing,M.L.Liu,21,Connection-oriented Datagram Socket,The connection is unilateral,that is,it is enforced only on one side.The socket on the other side is free to send and receive data to and from other sockets,unless it too commits to a connection to the other socket.See Example3Sender,Example3Receiver.,3/31/2023,Distributed Computing,M.L.Liu,22,The Stream-mode Socket API,The datagram socket API supports the exchange of discrete units of data(that is,datagrams).the stream socket API provides a model of data transfer based on the stream-mode I/O of the Unix operating systems.By definition,a stream-mode socket supports connection-oriented communication only.,3/31/2023,Distributed Computing,M.L.Liu,23,Stream-mode Socket API(connection-oriented socket API),3/31/2023,Distributed Computing,M.L.Liu,24,Stream-mode Socket API,A stream-mode socket is established for data exchange between two specific processes.Data stream is written to the socket at one end,and read from the other end.A stream socket cannot be used to communicate with more than one process.,3/31/2023,Distributed Computing,M.L.Liu,25,Stream-mode Socket API,In Java,the stream-mode socket API is provided with two classes:Server socket:for accepting connections;we will call an object of this class a connection socket.Socket:for data exchange;we will call an object of this class a data socket.,3/31/2023,Distributed Computing,M.L.Liu,26,Stream-mode Socket API program flow,3/31/2023,Distributed Computing,M.L.Liu,27,The server(the connection listener),3/31/2023,Distributed Computing,M.L.Liu,28,Key methods in the ServerSocket class,Note:Accept is a blocking operation.,3/31/2023,Distributed Computing,M.L.Liu,29,Key methods in the Socket class,A read operation on the InputStream is blocking.A write operation is nonblocking.,3/31/2023,Distributed Computing,M.L.Liu,30,Connection-oriented socket API-3,3/31/2023,Distributed Computing,M.L.Liu,31,Connection-oriented socket API-3,3/31/2023,Distributed Computing,M.L.Liu,32,Connectionless socket API,3/31/2023,Distributed Computing,M.L.Liu,33,Example 4 Event Diagram,3/31/2023,Distributed Computing,M.L.Liu,34,Example4,3/31/2023,Distributed Computing,M.L.Liu,35,Secure Socketshttp:/,Secure sockets perform encryption on the data transmitted.The JavaTM Secure Socket Extension(JSSE)is a Java package that enables secure Internet communications.It implements a Java version of SSL(Secure Sockets Layer)and TLS(Transport Layer Security)protocolsIt includes functionalities for data encryption,server authentication,message integrity,and optional client authentication.Using JSSE,developers can provide for the secure passage of data between a client and a server running any application protocol.,3/31/2023,Distributed Computing,M.L.Liu,36,The Java Secure Socket Extension APIhttp:/,Import.ssl;Class SSLServerSocket is a subclass of ServerSocket,and inherits all its methods.Class SSLSocket is a subclass of Socket,and inherits all its methods.There are also classes for CertificationHandshakingKeyManagerSSLsession,3/31/2023,Distributed Computing,M.L.Liu,37,Summary,In this chapter,we introduced the socket application program interface for interprocess communication.The socket API is widely available as a programming facility for IPC at a relatively low level of abstraction.,3/31/2023,Distributed Computing,M.L.Liu,38,Summary-2,Using the Java socket APIs,we introduced two types of sockets:The datagram sockets,which uses the User Datagram Protocol(UDP)at the transport layer to provide the sending and receiving of discrete data packets known as datagrams.The stream-mode socket,which uses the Tranport Layer Protocol(TCP)at the transport layer to provide the sending and receiving of data using a data stream.,3/31/2023,Distributed Computing,M.L.Liu,39,Summary-3,Key points of the Java datagram socket API:It supports both connectionless communication and connection-oriented communication.Each process must create a DatagramSocket object to send/receive datagrams.Each datagram is encapsulated in a DatagramPacket object.,3/31/2023,Distributed Computing,M.L.Liu,40,Summary-4,Key points of the Java datagram socket API continued:In connectionless communication,a datagram socket can be used to send to or receive from any other datagram socket;in connection-oriented communication,a datagram socket can only be used to send to or receive from the datagram socket attached to the other end of the connection.Data for a datagram are placed in a byte array;if a byte array of insufficient length is provided by a receiver,the data received will be truncated.The receive operation is blocking;the send operation is non-blocking.,3/31/2023,Distributed Computing,M.L.Liu,41,Summary-5,Key points of the Java stream-mode socket API:It supports connection-oriented communication only.A process plays the role of connection-acceptor,and creates a connection socket using the ServerSocket class.It then accepts connection requests from other processes.A process(a connection-requestor)creates a data socket using the Socket class,the constructor of which issues a connection request to the connection-acceptor.,3/31/2023,Distributed Computing,M.L.Liu,42,Summary-6,More key points of the Java stream-mode socket API:When a connection request is granted,the connection-acceptor creates a data socket,of the Socket class,to send and receive data to/from the connection-requestor.The connection-requestor can also send and/or receive data to/from the connection-acceptor using its data socket.The receive(read),the connection-accept operation,and the connection-request operations are blocking;the send(write)operation is non-blocking.The reading and writing of data into the socket of data stream are decoupled:they can be performed in different data units.See Figure 8.,3/31/2023,Distributed Computing,M.L.Liu,43,Summary-7,Key points of secure sockets:Secure socket APIs are available for transmission of confidential data.Well known secure socket APIs include the Secure Socket Layer(SSL)and Javas Secure Socket Extension(JSSE).Secure socket APIs have methods that are similar to the connection-oriented socket APIs.,

    注意事项

    本文(分布式计算原理与应用(DistributedComputing)第四章ppt课件.ppt)为本站会员(牧羊曲112)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开