Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network Programming CSE 132. iClicker/WUTexter Question How many of the following statements are true? In the model-view-controller paradigm, a swing.

Similar presentations


Presentation on theme: "Network Programming CSE 132. iClicker/WUTexter Question How many of the following statements are true? In the model-view-controller paradigm, a swing."— Presentation transcript:

1 Network Programming CSE 132

2 iClicker/WUTexter Question How many of the following statements are true? In the model-view-controller paradigm, a swing JSlider would be considered part of the model. A Java int is stored in 4 bytes. If the least significant bit of a two’s complement number is 1, then the value is negative. A Java double can be read atomically without the protection of a lock A: 0 B: 1 C: 2 D: 3 E: 4

3 Network Programming vs. Threads Threads Multiple independent execution sequences All on the same computer Utilize common memory for communication Read/write shared objects Network Programming Multiple independent execution sequences Across multiple computers Utilize network for communication Send/receive messages

4 Internet

5 Low-level Protocols Internet Protocol (IP) – Datagram transmission – Best effort delivery – Can be reordered Transmission Control Protocol (TCP) – Reliable stream built on IP – Uses sequence numbers for datagram ordering – Retransmits if necessary Combination known as TCP/IP

6 Addressing on the Internet Internet Protocol (IP) has “unique” ID for each machine on the network (at least in principal) IPv4 uses 32-bit (4-byte) address that is written as follows: a.b.c.d – where a, b, c, and d represent bytes with values between 0 and 255: 128.252.165.10 IPv6 uses 128-bit addresses for greater addressing range

7 Domain Name Service (DNS) Lookup service for names – Translate domain name into IP address – www.cse.wustl.edu  128.252.165.10

8 Internet

9 Sockets Stream abstraction for network communication Once established, use stream wrappers as with file I/O Client (sender) Server (receiver) socket TCP stream

10 Client Side Socket s = new Socket(“localhost”,10420); // “localhost” is short for this machine, alternative // is to provide IP address or domain name // Second parameter is port # (use 10,000 to 30,000) DataOutputStream dos = new DataOutputStream(s.getOutputStream()); dos.writeInt(4); DataInputStream dis = new DataInputStream(s.getInputStream()); int inpValue = dis.readInt();

11 ServerSocket

12 Server Side ServerSocket ss = new ServerSocket(10420); // port 10420 while (----) { Socket s = ss.accept(); DataInputStream dis = new DataInputStream(s.getInputStream()); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); while (----) { int inputValue = dis.readInt(); dos.writeInt(inputValue + 1); }

13 Protocol Design Knock-knock Programmer’s responsibility for common interpretation of bytes at sender and receiver – writeInt() sends 4-byte integer – readInt() receives 4-byte integer – writeByte() send 1 byte – readByte() receives 1 byte Recall dumpster from studio 2 We’ll explore this in studio 6 (next week)

14 iClicker/WUTexter Question I can invoke writeInt() on what type of object? A.FileOutputStream B.OutputStream C.DataOutputStream D.FileInputStream E.DataInputStream

15


Download ppt "Network Programming CSE 132. iClicker/WUTexter Question How many of the following statements are true? In the model-view-controller paradigm, a swing."

Similar presentations


Ads by Google