470 likes | 582 Views
Distributed Systems. Chapter 4 : Inter-Process Communication. Overview. Message passing send, receive, group communication synchronous versus asynchronous types of failure, consequences socket abstraction Java API for sockets connectionless communication (UDP)
E N D
Distributed Systems Chapter 4 : Inter-Process Communication Distributed Computing & Database Lab
Overview • Message passing • send, receive, group communication • synchronous versus asynchronous • types of failure, consequences • socket abstraction • Java API for sockets • connectionless communication (UDP) • connection-oriented communication (TCP) Distributed Computing & Database Lab
API for Internet programming... Applications, services RMI and RPC Middleware request-reply protocol This layers chapter marshalling and external data representation UDP and TCP Distributed Computing & Database Lab
Inter-process communication • Distributed systems • consist of Components (processes, objects) which communicate in order to co-operate and synchronize • rely on message passing, since no shared memory • Middleware provides programming language support, hence • does not support low-level untyped data primitives (Functions of operating system) • implements higher-level language primitives + typed data Distributed Computing & Database Lab
Inter-process communication ctd Possibly several processes on each host (use Ports). Send and receive primitives. A client node Host(server) node Logical Inter-Process Communication 분산 응용 Physical Inter-Process Communication Communication Network Communications System Distributed Computing & Database Lab
Communication service types • Connectionless: UDP • ‘send and receive(= pray)’ unreliable delivery • efficient and easy to implement • asynchronous communication • Connection-oriented: TCP • with basic reliability guarantees • less efficient, memory and time overhead for error correction • synchronous communication Distributed Computing & Database Lab
Connectionless service • UDP (User Datagram Protocol) • messages possibly lost, duplicated, delivered out of order, without telling the user • maintains no state information, so cannot detect lost, duplicate or out-of-order messages • each message contains source address and destination address • may discard corrupted messages due to no error correction (simple checksum) or congestion Used for DNS (Domain Name System) on Internet, and forrcp, rwho, RPC, HTTP(소용량화일), FTP(non-error bulk file) Distributed Computing & Database Lab
Connection-oriented service • TCP (Transmission Control Protocol) • establishes data stream connection to ensure reliable, in-sequence delivery • error checking and reporting to both ends • attempts to match speeds (timeouts, buffering) • sliding window: state information includes • unacknowledged messages • message sequence numbers • flow control information (matching the speeds) Used for FTP, HTTP(bulk file), stream data, Remote login(Telnet) on Internet. Distributed Computing & Database Lab
Timing issues in DSs • No global time • each system has a physical clock(local time) • Computer clocks • may have varying drift rate • rely on GPS radio signals (not always reliable), or synchronize via clock synchronization algorithms • Event ordering (message sending, arrival) • carry timestamps(based on global time) • may arrive in wrong order due to transmission delays (cf email) Distributed Computing & Database Lab
Failure issues in DSs • DSs expected to continue if failure has occurred: • message failed to arrive • process stopped (and others may detect this process) • process crashed (and others cannot detect this process) • Types of failures • Benign(자비를 베풀어야 할 타입) • omission, stopping, timing/performance • arbitrary (called Byzantine) • corrupt message, wrong method called, wrong result Distributed Computing & Database Lab
Class of failure Affects Description Fail-stop Process Process halts and remains halted. Other processes may detect this state. Crash Process Process halts and remains halted. Other processes may not be able to detect this state. Omission Channel A message inserted in an outgoing message buffer never arrives at the other end’s incoming message buffer. Send-omission Process A process completes a send, but the message is not put in its outgoing message buffer. Receive-omission Process A message is put in a process’s incoming message buffer, but that process does not receive it. Arbitrary Process or Process/channel exhibits arbitrary behaviour: it may (Byzantine) channel send/transmit arbitrary messages at arbitrary times, commit omissions; a process may stop or take an incorrect step. Omission and arbitrary failures( mentioned in Chapter 2, pp36-37 ) Distributed Computing & Database Lab
Types of interaction • Synchronous interaction model: • known upper/lower bounds on execution speeds, message transmission delays and clock drift rates • more difficult to build[implement], conceptually simpler model • use Queue(for waiting = blocking) • send and receive are blocking • Asynchronousinteraction model • arbitrary processes execution speeds, message transmission delays and clock drift rates • some problems impossible to solve (e.g. agreement) • Send is non-blocking, receive is blocking or non-blocking • if solutions valid for asynchronous, then also valid for synchronous. Distributed Computing & Database Lab
message Send and receive • Send • send a message to a socket bound to a process • can be blocking or non-blocking • Receive • receive a message on a socket • can be blocking or non-blocking • Broadcast/multicast • send to all processes or all processes in a group Distributed Computing & Database Lab
Communication type Blocking Send Blocking Receive Languages and systems Synchronous Asynchronous Asynchronous Yes No No Yes Yes No Occam Mach, Chorus,BSD 4.x UNIX Charlotte Receive • Blocked receive • destination process blocked until message arrives • most commonly used • Variations • conditional receive (continue until receiving indication that message arrived or polling) • timeout • selective receive (wait for message from one of a number of ports) Distributed Computing & Database Lab
Asynchronous Send • Characteristics: • unblocked (process continues after the message sent out) • buffering needed (at receive end) • mostly used with blocking receive • usable for multicast • efficient implementation • Problems • buffer overflow • error reporting (difficult to match error with message) • Maps closely onto connectionless service. Distributed Computing & Database Lab
Synchronous Send • Characteristics: • blocked (sender suspended until message received) • synchronization point for both sender & receiver • easier to reason about Synchronous Send • Problems • failure and indefinite delay causes indefinite blocking (해결: use Timeout) • multicasting/broadcasting not supported • implementation more complex • Maps closely onto connection-oriented service. Distributed Computing & Database Lab
Sockets and ports • Socket = Internet address + port number. • Only one receiver, but multiple senders per port. • Disadvantages: location dependence (but see Mach study, chap 18) • Advantages: several points of entry to the process • Port No(= 2**16 numbers, /etc/services ) 1-255: standard services,21: ftp, 23 : telnet,25: e-mail, 513 : login 1-1023: only system processes 1024-4099 : system and user processes, 5000<이상: only user processes * ephemeral 포트 번호 : 분산 응용 시 임시할당 포트번호 agreed port any port socket socket message client server other ports Internet address = 138.37.94.248 Internet address = 138.37.88.249 Distributed Computing & Database Lab
Sockets • Detailed Socket • Message destinations V : V-kernel MS windows : winsock Distributed Computing & Database Lab
Sockets ctd • Socket Layer • Characteristics: • Endpoint for inter-process communication • message transmission between sockets • socket associated with either UDP or TCP • processes bound to sockets can use multiple ports • no port sharing unless IP multicast • Implementations • Originally BSD Unix, but available in Linux, Windows(C language) • Windows Socket API • 참조 사이트 http://myhome.hanafos.com/~jaewon9980/Programming/winsock_api.htm# • http://icoder.tistory.com/88 • Java API for Internet programming Distributed Computing & Database Lab
Packages : Java.net, Java.io Distributed Computing & Database Lab
Java API for Internet addresses • JavaTM 2 PlatformStd. Ed. v1.3.1 • Class/Methods참조:사이트http://java.sun.com/j2se/1.3/docs/api/index.html http://java.sun.com/j2se/1.4.2/docs/api/index.html JavaTM 2 Platform, Standard Edition, v 1.4.2 API Specification http://download.oracle.com/javase/Java SE Technical Documentation http://download.oracle.com/javase/6/docs/api/index.html Java™ Platform, Standard Edition 6 API Specification • Class InetAddress • uses DNS (Domain Name System) InetAddress aC = InetAddress.getByName( “gromit.cs.bham.ac.uk” ); • throws UnknownHostException • encapsulates detail of IP address (4 bytes for IPv4, and 16 bytes for IPv6) Distributed Computing & Database Lab
Java API for Datagram Comms (UDP- package java.net ) • Simple send/receive, with messages possibly lost/out of order • Class DatagramPacket • packets may be transmitted between sockets • packets truncated if too long • provides methods(getData, getPort, getAddress…) Distributed Computing & Database Lab
Sending a message Receiving a message s = socket(AF_INET, SOCK_DGRAM, 0) s = socket(AF_INET, SOCK_DGRAM, 0) bind(s, ClientAddress) bind(s, ServerAddress) sendto(s, "message", ServerAddress) amount = recvfrom(s, buffer, from) ServerAddress and ClientAddress are socket addresses Java API for Datagram Comms ctd (UDP- package java.net ) • Class DatagramSocket • socket constructor(returns free port if no arg.) • send DatagramPacket, non-blocking • receive DatagramPacket, blocking • setSoTimeout(receive blocks for time T and throws InterruptedIOException) • connect • close DatagramSocket • throws SocketExceptionif port unknown or in use Distributed Computing & Database Lab
Java API for Datagram Comms( ex: DatagramSocket class) Distributed Computing & Database Lab
UDP client example: (UDP- package java.net )UDP client sends a message to the server and gets a reply import java.net.*; import java.io.*; public class UDPClient{ public static void main(String args[]){ // args give message contents and server hostname, that is args[0] =“message contents”, args[1]=“server hostname” try { DatagramSocketaSocket= new DatagramSocket(); byte [] m = args[0].getBytes(); InetAddressaHost = InetAddress.getByName( args[1]); int serverPort = 6789; DatagramPacketrequest = new DatagramPacket(m, args[0].length(), aHost, serverPort); aSocket.send(request);// To server 내aSocket.receive(request); byte[] buffer = new byte[1000]; DatagramPacketreply = new DatagramPacket(buffer, buffer.length); aSocket.receive(reply); // From server 내aSocket.send(reply); System.out.println("Reply: " + new String(reply.getData())); aSocket.close(); }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());} } } Distributed Computing & Database Lab
UDP server example: (UDP- package java.net )UDP server repeatedly receives a request and sends it back to the client import java.net.*; import java.io.*; public class UDPServer{ public static void main(String args[] ){ try{ DatagramSocketaSocket = new DatagramSocket(6789); byte[] buffer = new byte[1000]; while(true){ DatagramPacketrequest = new DatagramPacket(buffer, buffer.length); aSocket.receive(request);// From client내 aSocket.send(request); DatagramPacketreply = new DatagramPacket(request.getData(), request.getLength(), request.getAddress(), request.getPort()); aSocket.send(reply); // To client내 aSocket.receive(reply); } }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e) {System.out.println("IO: " + e.getMessage());} } } Distributed Computing & Database Lab
UDP client-server example: (UDP- package java.net ) import java.net.*; import java.io.*; public class UDPClient{ public static void main(String args[]){ // args give message contents and server hostname, that is args[0] =“message contents”, args[1]=“server hostname” try { DatagramSocketaSocket= new DatagramSocket(); byte [] m = args[0].getBytes(); InetAddressaHost = InetAddress.getByName(args[1]); int serverPort = 6789; DatagramPacketrequest = new DatagramPacket(m, args[0].length(), aHost, serverPort); aSocket.send(request);// To server 내aSocket.receive(request); byte[] buffer = new byte[1000]; DatagramPacketreply = new DatagramPacket(buffer, buffer.length); aSocket.receive(reply); // From server 내aSocket.send(reply); System.out.println("Reply: " + new String(reply.getData())); aSocket.close(); }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());} } } import java.net.*; import java.io.*; public class UDPServer{ public static void main(String args[] ){ try{ DatagramSocketaSocket = new DatagramSocket(6789); byte[] buffer = new byte[1000]; while(true){ DatagramPacketrequest = new DatagramPacket(buffer, buffer.length); aSocket.receive(request);// From client내 aSocket.send(request); DatagramPacketreply = new DatagramPacket(request.getData(), request.getLength(), request.getAddress(), request.getPort()); aSocket.send(reply); // To client내 aSocket.receive(reply); } }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e) {System.out.println("IO: " + e.getMessage());} } } Distributed Computing & Database Lab
Requesting a connection Listening and accepting a connection s = socket(AF_INET, SOCK_STREAM,0) s = socket(AF_INET, SOCK_STREAM,0) bind(s, ServerAddress); listen(s,5); // 5 : Maximum No. of Requests for connection that can be queued at this socket(s) connect(s, ServerAddress) sNew = accept(s, ClientAddress); write(s, "message", length) n = read(sNew, buffer, amount) ServerAddress and ClientAddress are socket addresses Java API for Data Stream Communications(TCP- package java.io) • Data stream abstraction • attempts to match the data between sender/receiver • marshaling/unmarshaling(ex, External Data Representation) • Class Socket • used by processes with a connection • connect, request sent from client[client-side socket] • accept, issued from server[ server-side socket]; waits for a connect request, blocked if none available Distributed Computing & Database Lab
Java API for Data Stream Communications – ctd (TCP- package java.io ) • Class ServerSocket • socket constructor (for listening at a server port) • getInputStream(), getOutputStream() in Class socket • DataInputStream, DataOutputStream class (automatic marshaling/unmarshaling) : 35page에서 설명 • closeto close a socket • raises UnknownHost, IOException, etc Distributed Computing & Database Lab
TCP client example : (TCP- package java.io ) TCP client makes connection to server, sends request and receives reply import java.net.*; // UTF is for Universal Transfer Format import java.io.*; public class TCPClient { public static void main (String args[]) { // arguments supply message and hostname of destination, that is args[0] =“message”, args[1]=“hostname” try{ int serverPort = 7896; Sockets = new Socket(args[1], serverPort); DataInputStreamin = new DataInputStream( s.getInputStream()); DataOutputStreamout = new DataOutputStream( s.getOutputStream()); out.writeUTF( args[0] );// To server내in.readUTF(); String data = in.readUTF(); // From server내out.writeUTF(data); System.out.println("Received: "+ data) ; s.close(); }catch (UnknownHostException e){ System.out.println("Sock:"+e.getMessage()); }catch (EOFException e){System.out.println("EOF:"+e.getMessage()); }catch (IOException e){System.out.println("IO:"+e.getMessage());} } } Distributed Computing & Database Lab
TCP server example : (TCP- package java.io ) TCP server makes a connection for each client and then echoes the client’s request import java.net.*; import java.io.*; public class TCPServer { public static void main (String args[] ) { try{ int serverPort = 7896; ServerSocket listenSocket = new ServerSocket(serverPort); while(true) { SocketclientSocket = listenSocket.accept(); Connectionc = new Connection(clientSocket); } } catch(IOException e) {System.out.println("Listen :"+e.getMessage());} } } // this figure continues on the next slide Distributed Computing & Database Lab
TCP server example ctd : (TCP- package java.io ) TCP server makes a connection for each client and then echoes the client’s request class Connection extends Thread { DataInputStream in; DataOutputStream out; Socket clientSocket; public Connection (Socket aClientSocket) { try { clientSocket = aClientSocket; in = new DataInputStream( clientSocket.getInputStream()); out =new DataOutputStream( clientSocket.getOutputStream()); this.start(); } catch(IOException e) {System.out.println("Connection:"+e.getMessage());} } public void run(){ try { // an echo server String data = in.readUTF();// From client내 out.writeUTF(); out.writeUTF(data);// To client내 in.readUTF(); clientSocket.close(); } catch(EOFException e) {System.out.println("EOF:"+e.getMessage()); } catch(IOException e) {System.out.println("IO:"+e.getMessage());} } } Distributed Computing & Database Lab
TCP Client-server example (TCP- package java.io ) class Connection extends Thread { DataInputStream in; DataOutputStream out; Socket clientSocket; public Connection (Socket aClientSocket) { try { clientSocket = aClientSocket; in = new DataInputStream( clientSocket.getInputStream()); out =new DataOutputStream( clientSocket.getOutputStream()); this.start(); } catch(IOException e) {System.out.println("Connection:"+e.getMessage());} } public void run(){ try { // an echo server String data = in.readUTF();// From client내 out.writeUTF(); out.writeUTF(data);// To client내 in.readUTF(); clientSocket.close(); } catch(EOFException e) {System.out.println("EOF:"+e.getMessage()); } catch(IOException e) {System.out.println("IO:"+e.getMessage());} } } import java.net.*; // UTF is for Universal Transfer Format import java.io.*; public class TCPClient { public static void main (String args[]) { // arguments supply message and hostname of destination, that is args[0] =“message”, args[1]=“hostname” try{ int serverPort = 7896; Sockets = new Socket(args[1], serverPort); DataInputStreamin = new DataInputStream( s.getInputStream()); DataOutputStreamout = new DataOutputStream( s.getOutputStream()); out.writeUTF(args[0]);// To server내in.readUTF(); String data = in.readUTF(); // From server내out.writeUTF(data); System.out.println("Received: "+ data) ; s.close(); }catch (UnknownHostException e){ System.out.println("Sock:"+e.getMessage()); }catch (EOFException e){System.out.println("EOF:"+e.getMessage()); }catch (IOException e){System.out.println("IO:"+e.getMessage());} } } import java.net.*; import java.io.*; public class TCPServer { public static void main (String args[] ) { try{ int serverPort = 7896; ServerSocket listenSocket = new ServerSocket(serverPort); while(true) { SocketclientSocket = listenSocket.accept(); Connectionc = new Connection(clientSocket); } } catch(IOException e) {System.out.println("Listen :"+e.getMessage());} } } Distributed Computing & Database Lab
In the examples... • UDP • UDP Client • sends a message and gets a reply • UDP Server • repeatedly receives a request and sends it back to the client • TCP • TCP Client • makes connection, sends a request and receives a reply • TCP Server • makes a connection for each client and then echoes the client’s request Distributed Computing & Database Lab
T y p e Re pr e s e n ta t i o n s e q ue n ce l e n g th ( u n si g n ed l o n g ) fo ll ow ed b y el e m e nt s i n o r d e r s t ri n g l e n g th ( u n si g n ed l o n g ) fo ll ow ed b y ch a ra c te rs i n o r d e r ( ca n al so ca n h av e w i de ch a ra c te rs) a r ra y a rr ay e le m e n t s i n o r de r ( n o l en g t h s p e ci f ie d b eca us e i t is f i x e d ) s t ru ct i n t he or de r o f de c la r at i o n o f t he co mp o n e n t s e n u m e r a t e d u n s i g n e d l o n g ( t h e v a l ue s a re s pe c i f ie d b y t he o r de r d ec l ar e d ) u ni o n t y p e ta g f o l l o we d b y t h e s el e cte d m e mb er Data Marshaling/Unmarshaling-CORBA • Marshaling (=conversion of data into machine-independent format) • Client(local data format)marshallingglobal data format unmarshallingserver(local data format) • necessary due to heterogeneity & varying formats of internal data representation (of each system) • Sun-XDR(External Data Representation) : SUN- NFS (see chapter 8) • Approaches(CORBA, JAVA) • CORBA CDR (Common Data Representation) Client Server Local data format1 Local data format2 Golbal Data Format Send message Golbal Data Format Replay message Distributed Computing & Database Lab
notes index in on representation sequence of bytes 4 bytes length of string 5 0–3 "Smit" 4–7 ‘Smith’ "h___" 8–11 12–15 6 length of string "Lond" 16–19 ‘London’ "on__" 20-23 1934 24–27 unsigned long The flattened form represents a Person struct with value: {‘Smith’, ‘London’, 1934} Data Marshaling/Unmarshaling-CORBA ctd • Marshalling in CORBA struct Person{ string name; string place; long year;}; Distributed Computing & Database Lab
Explanation Serialized values Person 8-byte version number h0 class name, version number java.lang.String java.lang.String number, type and name of int year 3 name: place: instance variables 1934 5 Smith 6 London h1 values of instance variables The true serialized form contains additional type markers; h0 and h1 are handles Data Marshaling/Unmarshaling- Java RMI • Java object serialization{ Person p = new Person(1934, “Smith”, “London”); } • Java class = Person struct defined in CORBA IDL public class Personimplements Serializable { private String name; private String place; private int year; public Person(String aName, String aPlace, int aYear) { name = aName; place = aPlace; year = aYear } // followed by methods for accessing the instance variables } • Java class : Java serialization form Distributed Computing & Database Lab
32 bits 32 bits 32 bits 32 bits interface of Internet address port number time object number remote object Remote Object Reference • An identifier for an object that is valid throughout the distributed system • must be unique • may be passed as argument, hence need external representation client Logical Inter-Process Communication Server 분산 응용 Distributed Computing & Database Lab Communication Network
Client Server Request doOperation getRequest message Select object Execute method (wait) Reply sendReply message (continuation) Client-server Communication : Request-Reply protocols Distributed Computing & Database Lab
Operations of Request-Reply, its message structure • public byte[] doOperation (RemoteObjectRef o, int methodId, byte[] arguments) • sends a request message to the remote object, and returns the reply. • the arguments specify the remote object, the method to be invoked and the arguments of that method. • public byte[] getRequest (); • acquires a client request via the server port. • public void sendReply (byte[] reply, InetAddress clientHost, int clientPort); • sends the reply message, reply to the client at its Internet address and port. messageType int (0=Request, 1= Reply) requestId int RemoteObjectRef objectReference int or Method methodId array of bytes arguments Distributed Computing & Database Lab
N a m e M es sag es s e nt b y C li e nt S e r ve r C li e nt R R e qu es t R R R e pl y R e qu es t R R A R e pl y A ck no w ledg e re ply R e qu es t Client-Server Communication : RPC exchange protocols • Request-reply: • port must be known to client processes (usually published on a server) • client has a private port to receive replies • Other schemes(RPC exchange protocols ): Distributed Computing & Database Lab
Group Communication • Multicast message’s characteristics • Fault-tolerance based on replicated services • Finding discovery server • Better performance through replicated data • Event notifications • Ex, Dealing room system • IP multicast • IP multicast • Multicast router • Multicast address allocation • 224.0.0.1 – 224.0.0.255 • Java API to IP multicast • Class MulticastSocketwhich is a subclass of DatagramSocket Distributed Computing & Database Lab
Java API to IP multicast:Multicast peer joins a group and sends and receives datagrams import java.net.*; import java.io.*; public class MulticastPeer{ public static void main(String args[ ] ){ // args give message contents & destination multicast group (e.g. "228.5.6.7") try { InetAddressgroup = InetAddress.getByName( args[1] ); MulticastSockets = new MulticastSocket(6789); s.joinGroup(group); byte [] m = args[0].getBytes(); DatagramPacketmessageOut = new DatagramPacket(m, m.length, group, 6789); s.send(messageOut); // To s.receive(messageIn); // this figure continued on the next slide // Use Class MulticastSocket(as a subclass of DatagramSocket) Distributed Computing & Database Lab
Java API to IP multicast ctdMulticast peer joins a group and sends and receives datagrams // get messages from others in group byte[] buffer = new byte[1000]; for(int i=0; i< 3; i++) { DatagramPacket messageIn = new DatagramPacket(buffer, buffer.length); s.receive(messageIn); // From s.send(messageOut); System.out.println("Received:" + new String(messageIn.getData())); } s.leaveGroup(group); }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());} } } Distributed Computing & Database Lab
Java API to IP multicast ctdMulticast peer joins a group and sends and receives datagrams import java.net.*; import java.io.*; public class MulticastPeer{ public static void main(String args[ ]){ // args give message contents & destination multicast group (e.g. "228.5.6.7") try { InetAddressgroup = InetAddress.getByName(args[1]); MulticastSockets = new MulticastSocket(6789); s.joinGroup(group); byte [] m = args[0].getBytes(); DatagramPacketmessageOut = new DatagramPacket(m, m.length, group, 6789); s.send(messageOut); // To s.receive(messageIn); // Use Class MulticastSocket(as a subclass of DatagramSocket) // get messages from others in group byte[] buffer = new byte[1000]; for(int i=0; i< 3; i++) { DatagramPacket messageIn = new DatagramPacket(buffer, buffer.length); s.receive(messageIn); // From s.send(messageOut); System.out.println("Received:" + new String(messageIn.getData())); } s.leaveGroup(group); }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());} } } Distributed Computing & Database Lab
Requesting a connection Listening and accepting a connection Sending a message Receiving a message s = socket(AF_INET, SOCK_DGRAM, 0) s = socket(AF_INET, SOCK_STREAM,0) s = socket(AF_INET, SOCK_DGRAM, 0) s = socket(AF_INET, SOCK_STREAM,0) bind(s, ServerAddress); listen(s,5); // 5 : Maximum No. of Requests for connection that can be queued at this socket(s) bind(s, ClientAddress) bind(s, ServerAddress) connect(s, ServerAddress) sNew = accept(s, ClientAddress); sendto(s, "message", ServerAddress) amount = recvfrom(s, buffer, from) write(s, "message", length) n = read(sNew, buffer, amount) ServerAddress and ClientAddress are socket addresses ServerAddress and ClientAddress are socket addresses Case Study –communication in Unix • Datagram communication(UDP) • Stream communication(TCP) Distributed Computing & Database Lab
Summary • IPC provides high-level language + typed data primitives: • socket abstraction, send/receive • synchronous/asynchronous communication • Java classes (different from operating system primitives) • automatic marshaling of data into machine-independent format • For Java API to IP Multicast: • Use Class MulticastSocket(as a subclass of DatagramSocket) • 참고 • Windows Socket API • 참조 사이트 http://myhome.hanafos.com/~jaewon9980/Programming/winsock_api.htm# http://icoder.tistory.com/88 http://download.oracle.com/javase/6/docs/api/index.html Java™ Platform, Standard Edition 6 API Specification Distributed Computing & Database Lab