{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

3- socket_and_android

3- socket_and_android - CSE 486/586 Distributed Systems...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Socket Programming and Android Steve Ko Computer Sciences and Engineering University at Buffalo
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 Last Time What to put on top of physical networks? Layers providing survivability Where to put functionalities? Fate-sharing & end-to-end arguments IP layer doesn’t provide much TCP handles most of the survivability issues TCP & UDP : the two transport protocols of the Internet What interface do applications see? Socket API 2
Image of page 2
CSE 486/586, Spring 2012 Today Today: background for programming assignments Socket programming, Android, and project overviews It’s imperative that you try yourself! If you have no clue at the end of the lecture, please stop by my office. Goal: today’s really about transferring basic knowledge , less about design decisions. 3
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 Today’s Question TCP provides a reliable, byte-stream connection as an abstraction. UDP gives raw access to what the IP network provides without all the overhead of TCP. So, how do we program applications on top of these abstractions? 4
Image of page 4
CSE 486/586, Spring 2012 What Applications See 5 TCP UDP IP Device Drivers Network Interface OS App Socket API
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 6 UNIX Socket API Socket interface Originally provided in Berkeley UNIX Later adopted by all popular operating systems Simplifies porting applications to different OSes In UNIX, everything is like a file All input is like reading a file All output is like writing a file File is represented by an integer file descriptor API implemented as system calls E.g., socket(), connect(), listen(), read(), write(), close(), … Will look at the details of these system calls
Image of page 6
CSE 486/586, Spring 2012 So, Let’s Consider a Scenario What is the server address? IP address How do we identify the Web server? Port number 7 OS Socket API OS Socket API IP network
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 8 Using Ports to Identify Services Web server ( port 80 ) Client host Server host 128.2.194.242 Echo server (port 7) Service request for 128.2.194.242 : 80 (i.e., the Web server) Web server (port 80) Echo server ( port 7 ) Service request for 128.2.194.242 : 7 (i.e., the echo server) OS OS Client Client
Image of page 8
CSE 486/586, Spring 2012 9 Knowing What Port Number To Use Popular applications have well-known ports E.g., port 80 for Web and port 25 for e-mail See http://www.iana.org/assignments/port-numbers Well-known vs. ephemeral ports Server has a well-known port (e.g., port 80) » Between 0 and 1023 Client picks an unused ephemeral (i.e., temporary) port » Between 1024 and 65535 Uniquely identifying the traffic between the hosts Two IP addresses and two port numbers Underlying transport protocol (e.g., TCP or UDP)
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 486/586, Spring 2012 10 Typical Client Program E.g. browser Prepare to communicate Create a socket Determine server IP address and port number (e.g., for a Web server) Initiate the connection to the server Exchange data with the server Write data to the socket Read data from the socket Do stuff with the data (e.g., render a Web page) Close the socket
Image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern