DOC PREVIEW
Berkeley COMPSCI 61A - Lecture 20

This preview shows page 1-2-14-15-29-30 out of 30 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS61A Lecture 20Clicker poll Goals for the daySlide 4Internet Basics SOMEONE IS TAKING THE EXAM TOMORROW!Slide 6Internet BasicsSlide 8Slide 9Slide 10Lots of applications on your computer connect to the internetThree way handshakeWhat REALLY happens on phone calls (TCP handles this)Our IM WorldOur IM - Three way handshake3-way handshakeStarting a ServerA client connecting to a serverA client can send a message to another clientWhat do you need to know?Servers and Clients Common Functionality Request ADT im-common.scmServers and Clients Common Functionality im-common.scmim-enroll-psuedoim-enrollrequest-handler is called when a new message is availableSlide 26when-port-readableSlide 28Telling the hardware how to let you know there is a new requestimCS61A Lecture 202011-07-25Colleen Lewis1Clicker poll  What chat client do you use? A)TrillianB)GChatC)iChatD)Facebook chatE)OtherDon’t vote if you don’t use one.SOMEONE IS TAKING THE EXAM TOMORROW!2Goals for the day•Introduction to some technical details about the internet–IP Addresses–Sockets–3-way handshake•Callbacks – call this function when X happens•More practice with BIG programss3Clicker poll  Is your home computer connected directly to the internet when you’re logged on to facebook? A)NoB)Yes4Internet BasicsSOMEONE IS TAKING THE EXAM TOMORROW!http://www.youtube.com/watch?v=qv0XCaUkfNk5Clicker poll  Is your home computer connected directly to the internet when you’re logged on to facebook? A)NoB)Yes6Internet Basicshttp://www.youtube.com/watch?v=7_LPdttKXPc7Clicker poll  When you send information through the internet, the information is broken up into multiple: A)PackagesB)PacketsC)PairsD)ListsE)Other8Clicker poll  These direct your packets within the internet to help them find their way? A)ISPsB)RoutersC)ServersD)WiresE)More than one of the above9Clicker poll  Webpages ARE:A)Files on routersB)Files on serversC)Files on public computersD)ServersE)Routers10Lots of applications on your computer connect to the internet11All have the same IP addressEach application creates a unique line of communication called a socketCreating a line of communication (socket) is a lot like starting a cell phone conversationThey may use different ports (like apartment number)Three way handshake12HelloSo…HiClientServerWhat REALLY happens on phone calls(TCP handles this)13HelloClientServerHelloHelloHelloHelloHelloHelloHelloHiHiOur IM Worldim-client im-serverSTk SocketsInternet (TCP/IP)14Our IM - Three way handshake15HelloThanksWelcomeClientServer3-way handshakeProblems with the 3-way handshake?A)Wasteful – could just do a 2-way handshakeB)Not enough – need a 4-way handshakeC)The connect might stop workingD)Multiple answers above are correctE)None of the aboveSOMEONE IS TAKING THE EXAM TOMORROW!16Starting a ServerSTk> (load "~cs61a/lib/im-server.scm")okaySTk> (im-server-start)Server starting...Server IP address: 128.32.48.187, server port: 46990(im-server-start) done.okay17ServerA client connecting to a server18ClientSTk> (load "~cs61a/lib/im-client.scm")okaySTk> (im-enroll "128.32.48.187" 46990)Sending 'hello' request to server.Waiting for 'welcome' from server.Response received: (server cs61a-tf welcome ())Received 'welcome' message.Sending 'thanks'.(im-enroll) done. okayThis created a socketA client can send a message to another client19ClientSTk> (im 'cs61a-tf "hi - how are you?")okaySTk> (im-exit)What do you need to know?•What is a socket?–An established line of communication •What is a 3-way handshake?–Sequence of messages to set-up a socket•Why do we need a 3-way handshake?–To ensure the communication line is bi-directional•How do you run the code?20Server Client(im-server-start) (im-enroll "123.4.56.8" 333)(im 'name "my message")(im-server-close) (im-exit)Servers and Clients Common Functionality Request ADT im-common.scm(define (make-request src dst action data) (list src dst action data))(define (request-src req) (list-ref req 0))(define (request-dst req) (list-ref req 1))(define (request-action req) (list-ref req 2))(define (request-data req) (list-ref req 3))21Clients and servers send requestsServers and Clients Common Functionality im-common.scm(define (send-request req write-port)...(define (get-request read-port)...22Don’t worry about how these work.They work.What are these?im-enroll-psuedo(define (im-enroll-psuedo server-address port) (set! socket-to-server (make-client-socket server-address port)) (set! port-to-server (socket-output socket-to-server)) (set! port-from-server (socket-input socket-to-server)) (send-request (make-request 'colleen 'server 'hello "") port-to-server) (get-request port-from-server) ;; omitted - confirm it is the message 'welcome (send-request (make-request 'colleen 'server 'thanks "") port-to-server) (setup-request-handler port-from-server))23im-enroll(define (im-enroll server-address port) (set! socket-to-server ... (set! port-to-server ... (set! port-from-server ...Based upon the code from the previous slide, the 3 variables that were set with set! must be:A)Shared by the client and serverB)Defined in the client codeC)Defined in the server codeD)Neither – these must be NEW variableE)Nothing can be inferred 24request-handler is called when a new message is available(define (request-handler-psuedo) (let ((req (get-request port-from-server))) (let ((action (request-action req)) (message (request-data req))) (cond ((equal? 'receive-msg action) (display message)) ((equal? 'goodbye action) ... )))))25im-enroll-psuedo(define (im-enroll-psuedo server-address port) (set! socket-to-server (make-client-socket server-address port)) (set! port-to-server (socket-output socket-to-server)) (set! port-from-server (socket-input socket-to-server)) (send-request (make-request 'colleen 'server 'hello "") port-to-server) (get-request port-from-server) ;; omitted - confirm it is the message 'welcome (send-request (make-request 'colleen 'server 'thanks "") port-to-server) (setup-request-handler port-from-server))26when-port-readable(define (setup-request-handler-psuedo port-from-server) (when-port-readable ;spec. formport-from-server request-handler))27Whenever new information comes in It will call this functionwhen-port-readable•What function in the server do you think calls when-port-readable?A. (im-server-start)B.(im-server-close)C.(handshake sock)D.(register-client name sock)E. All of the


View Full Document

Berkeley COMPSCI 61A - Lecture 20

Documents in this Course
Lecture 1

Lecture 1

68 pages

Midterm

Midterm

5 pages

Midterm

Midterm

6 pages

Lecture 35

Lecture 35

250 pages

Lecture 14

Lecture 14

125 pages

Lecture 2

Lecture 2

159 pages

Lecture 6

Lecture 6

113 pages

Lecture 3

Lecture 3

162 pages

Homework

Homework

25 pages

Lecture 13

Lecture 13

117 pages

Lecture 29

Lecture 29

104 pages

Lecture 11

Lecture 11

173 pages

Lecture 7

Lecture 7

104 pages

Midterm

Midterm

6 pages

Midterm

Midterm

6 pages

Lecture 8

Lecture 8

108 pages

Lab 4

Lab 4

4 pages

Lecture 7

Lecture 7

52 pages

Lecture 20

Lecture 20

129 pages

Lecture 15

Lecture 15

132 pages

Lecture 9

Lecture 9

95 pages

Lecture 30

Lecture 30

108 pages

Lecture 17

Lecture 17

106 pages

Load more
Download Lecture 20
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 20 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 20 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?