Docsity

CECS 327: Net-centric Computing - Connection-oriented Datagram & Stream Sockets - Prof. Je, Study notes of Computer Science

Partial preview of the text

Download CECS 327: Net-centric Computing - Connection-oriented Datagram & Stream Sockets - Prof. Je and more Study notes Computer Science in PDF only on Docsity!

02/25/2009 CECS 327: Net-centric Computing :: Distributed Computing by M.L. Liu 1

The Socket API (2)

Instructor: Dr. Jeho Park

Previously...

• Socket API

• UDP and TCP

• Java Socket API

• Datagram sockets and Stream sockets

• Connectionless datagram socket API

• Know what you did last time in the lab

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 using
the socket, an IllegalArgumentException will occur.
  • If a datagram from another socket is sent to this socket,
the data will be ignored.

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.

Stream-mode Socket API (connection-oriented socket API)

Sockets... Well... a lot of sockets.

Stream-mode Socket API In Java, the stream-mode socket API is provided with two classes:

  • ServerSocket: 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.

Stream-mode Socket API program flow

(client)

Key methods in the ServerSocket class

Note: Accept is a blocking operation.

Key methods in the Socket class

A read operation on the InputStream is blocking.

A write operation is nonblocking.

Connection-oriented socket API Client-Server type

Connectionless socket API

Example4 Event Diagram

accept connect request (from Socket constructor) read write message close data socket close connection socket close data socket ConnectionAcceptor ConnectionRequestor connection acceptance happened before the read at the ConnectionRequestor

Secure Sockets

http://java.sun.com/products/jsse/

• Secure sockets perform encryption on the data transmitted.

• The Java

TM

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) protocols

• It 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.