1 / 7

Advanced UNIX programming

Advanced UNIX programming. Fall 2002 Instructor: Ashok Srinivasan Lecture 28. Acknowledgements: The syllabus and power point presentations are modified versions of those by T. Baker and X. Yuan. Announcements. Reading assignment Chapter 14 Sections 14.1, 14.2, 14.4, and 14.5 Chapter 23

acleveland
Download Presentation

Advanced UNIX programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced UNIX programming Fall 2002 Instructor: Ashok Srinivasan Lecture 28 Acknowledgements: The syllabus and power point presentations are modified versions of those by T. Baker and X. Yuan

  2. Announcements • Reading assignment • Chapter 14 • Sections 14.1, 14.2, 14.4, and 14.5 • Chapter 23 • Quiz Monday • Project: Outline due Monday • Midterm 2 • Bonus points test • 20 Nov 2002

  3. Week 10 Topics • Advanced UDP sockets • Reliable communication over UDP • Time out • Sequence numbers • Unix domain protocols • Address structure • Client-server

  4. Unix domain protocols • Used for client-server communication on a single machine • Use same API as with regular client-server • Both stream and datagram sockets are supported • Why do we need this? • Efficiency • Passing file descriptors • More security checks

  5. Address structure • Open a socket using UNIX domain socket socket(AF_LOCAL, SOCK_STREAM, 0) socket(AF_LOCAL, SOCK_DGRAM, 0) • Use AF_UNIX instead of AF_LOCAL for portability • UNIX domain socket address structure #include <sys/un.h> struct sockaddr_un { uint8_t sun_len; sa_family_t sun_family; /*AF_LOCAL or AF_UNIX */ char sun_path[104]; /* path name */ }

  6. Binding a Unix domain socket • example1.c • Use absolute path for path name • bind will fail if the file exists • Pathname can potentially overrun the sun_path buffer • Otherwise, it is very similar to a TCP socket

  7. Client-server • example2.c and example3.c • connect needs a pathname that is currently bound to an open UNIX domain socket of the same type • Permission test for connect is the same as that for open with write-only access • connect will fail if the listening queue is full • UNIX domain datagram sockets are similar to UDP sockets • Sender must bind first for the receiver to reply

More Related