network programming cse 132. iclicker/wutexter question how many of the following statements are...

15
Network Programming CSE 132

Upload: maximillian-bryan

Post on 29-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

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

Network Programming

CSE 132

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

iClicker/WUTexter QuestionHow 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

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

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

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

Internet

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

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

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

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

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

Domain Name Service (DNS)

• Lookup service for names– Translate domain name into IP address– www.cse.wustl.edu 128.252.165.10

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

Internet

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

Sockets

• Stream abstraction for network communication• Once established, use stream wrappers as with

file I/O

Client(sender)

Server(receiver)

socket socket

TCP stream

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

Client SideSocket 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();

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

ServerSocket

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

Server SideServerSocket ss = new ServerSocket(10420); // port 10420while (----) {

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

}}

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

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)

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

iClicker/WUTexter QuestionI can invoke writeInt() on what type of object?

A. FileOutputStreamB. OutputStreamC. DataOutputStreamD. FileInputStreamE. DataInputStream

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