Download presentation
Presentation is loading. Please wait.
Published byAshley Ford Modified over 9 years ago
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 protocolsUnix 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 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.