Lecture 10 Overview!

Size: px
Start display at page:

Download "Lecture 10 Overview!"

Transcription

1 Lecture 10 Overview! Last Lecture! Wireless Sensor Networks! This Lecture! Daemon processes and advanced I/O functions! Source: Chapters 13 &14 of Stevens book! Next Lecture! Unix domain protocols and non-blocking I/O! Source: Chapters 15 & 16 of Stevens book! TELE Lecture 10 Daemon processes and advanced I/O functions 1

2 daemon! A daemon is a process that runs in the background and is independent of control from all terminals! Reasons for daemons independence of terminals! Prevent daemons error message from appearing on a user s terminal! Signals generated from terminal keys must not affect any daemons that were started from that terminal earlier! Ways to start a daemon! Started by the system initialization scripts! Started by inetd superserver! Performed by cron daemon on a regular basis! Started from user terminals (foreground or background)! TELE Lecture 10 Daemon processes and advanced I/O functions 2

3 syslogd daemon! How it works?! Read the configuration file /etc/syslog.conf! A Unix domain socket is created and bound to the pathname /var/run/log! A UDP socket is created and bound to port 514! The pathname /dev/klog is opened to read kernel error messages! Runs in an infinite loop that calls select, waiting for any one of the above descriptors to be readable, reads the log message, and does what the configuration file says to do with that message.! If the daemon receives the SIGHUP signal, it rereads the configuration file! TELE Lecture 10 Daemon processes and advanced I/O functions 3

4 syslog function! How to send log messages?! create a Unix domain datagram socket and send our messages to the pathname the daemon has bound, or send them to port 514 by a UDP socket! syslog function! An easy interface to the syslogd daemon! void syslog(int priority, const char *message, );! priority is a combination of a level and a facility shown later! message is like a format string to printf, with the addition of a %m specification, which is replaced with the error message corresponding to the current value of errno.! TELE Lecture 10 Daemon processes and advanced I/O functions 4

5 level! Log messages have a level between 0 and 7! If no level is specified, LOG_NOTICE is the default! TELE Lecture 10 Daemon processes and advanced I/O functions 5

6 facility! Identify the type of process sending the message! If no facility is specified, LOG_USER is the default! TELE Lecture 10 Daemon processes and advanced I/O functions 6

7 Example for syslog! The following call could be issued by a mail daemon when a call to open unexpectedly fails:! syslog(log_info LOG_MAIL, open(%s ): %m, file);! When an application calls syslog for the first time, it creates a Unix domain datagram socket and then calls connect to the well-known pathname of the socket created by the syslogd daemon. This socket remains open until the process terminates.! Alternatively, the process can call openlog and closelog! void openlog(const char *ident, int options, int facility);! ident is a string that will be inserted in front of each log message! options is formed as the logical OR of one or more of the constants in Figure 12.3! facility specifies a default facility! void closelog(void);! TELE Lecture 10 Daemon processes and advanced I/O functions 7

8 Options for openlog! TELE Lecture 10 Daemon processes and advanced I/O functions 8

9 daemon_init function! Control flow of daemon_init (refer to attachment 1: lib/ daemon_init.c)! fork: change the process into a child process! setsid: create a new session and the process becomes the session leader and group leader! Ignore SIGHUP and fork again, so that the daemon cannot automatically acquire a controlling terminal should it open a terminal device in the future. We must ignore SIGHUP because when the session leader terminates, all processes in the session are sent the SIGHUP signal! Set flag for error functions (err_xxx) so that they send error messages to syslogd. We cannot use printf to print any error message from a daemon (because of no controlling terminal)! Change working directory and clear file mode creation mask! Close any open descriptors! openlog for errors! TELE Lecture 10 Daemon processes and advanced I/O functions 9

10 inetd daemon! With systems before 4.3BSD, each service, such as FTP and Telnet, had a process associated with it, which is started at boot time.! All these daemons contained nearly identical startup code, first with respect to socket creation, and also with respect to becoming a daemon process (similar to the daemon_init function).! Each daemon took a slot in the process table, but each daemon was asleep more of the time.! Since 4.3BSD release, it was simplified by providing an Internet superserver: the inetd daemon! It simplifies writing daemon process since most of the startup details are handled by inetd. This obviates the need for each server to the daemon_init function.! It allows a single process (inetd) to be waiting for incoming client requests for multiple services, instead of one process for each service. This reduces the total number of processes in the system.! TELE Lecture 10 Daemon processes and advanced I/O functions 10

11 inetd daemon (cont.)! The inetd process establishes itself as a daemon using the techniques described in the daemon_init function. It then reads and processes its configuration file, typically /etc/inetd.conf. This file specifies the services that the superserver is to handle, and what to do when a service request arrives.! Some sample lines are:!! ftp stream tcp nowait root /usr/bin/ftpd ftpd -1 telnet stream tcp nowait root /usr/bin/telnetd telnetd login stream tcp nowait root /usr/bin/rlogind rlogind -s TELE Lecture 10 Daemon processes and advanced I/O functions 11

12 inetd daemon! TELE Lecture 10 Daemon processes and advanced I/O functions 12

13 Service handled by inetd! TELE Lecture 10 Daemon processes and advanced I/O functions 13

14 Service handled by inetd (cont.)! TELE Lecture 10 Daemon processes and advanced I/O functions 14

15 Daemon invoked by inetd! Control flow (refer to inetd/daytimetcpsrv3.c)! Set daemon flag so that err_xxx can print error messages to syslogd! openlog! Use getpeername to find out the peer address! Receive requests from the client by reading from the descriptor 0! Send response to the client! Close connection.! TELE Lecture 10 Daemon processes and advanced I/O functions 15

16 tcpd! Control flow! Check the client IP address using getpeername! Check the service (port number) using getsockname! Compare the above with the corresponding entries in hosts.allow and hosts.deny files and then decide if the connection should be closed or not! If the connection is allowed, call exec to start the server (using argv)! TELE Lecture 10 Daemon processes and advanced I/O functions 16

17 Socket timeouts! Three ways to place a timeout on an I/O operation involving a socket! Call alarm, which generates the SIGALRM signal when the specified time has expired (refer to Appendix 2: lib/ connect_timeo.c)! Block waiting for I/O in select, which has a time limit as an argument (refer to Appendix 3: lib/readable_timeo.c)! Use the newer SO_RCVTIMEO and SO_SNDTIMEO socket options (refer to Appendix 4: advio/dgclitimeo2.c)! The important point for the programmer is to find out how to test the timeout condition.! TELE Lecture 10 Daemon processes and advanced I/O functions 17

18 recv and send! Prototype! ssize_t recv(int sockfd, void *buff, size_t nbytes, int flags);! ssize_t send(int sockfd, const void *buff, size_t nbytes, int flags);! Both return: number of bytes read or written if OK, -1 on error! The first three arguments are the same as the first three arguments to read and write! flags is either 0, or is formed by logically OR ing one or more of the constants shown in Figure 13.6! TELE Lecture 10 Daemon processes and advanced I/O functions 18

19 Constants for flags! TELE Lecture 10 Daemon processes and advanced I/O functions 19

20 readv and writev! Prototype! ssize_t readv(int filedes, const struct iovec *iov, int iovcnt);! Called scatter read since the input data is scattered into multiple application buffers! ssize_t writev(int filedes, const struct iovec *iov, int iovcnt);! Called gather write since multiple buffers are gathered for a single output operation.! Both return: number of bytes read or written if OK, -1 on error! struct iovec { void *iov_base;! size_t iov_len;};! iovcnt is the number of elements in the array of iovec structures! TELE Lecture 10 Daemon processes and advanced I/O functions 20

21 recvmsg and sendmsg! Prototype! ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);! ssize_t sendmsg(int sockfd, struct msghdr *msg, int flags);! Both return: number of bytes read or written if OK, -1 on error! struct msghdr { void *msg_name;! socklen_t msg_namelen;! struct iovec *msg_iov;! size_t msg_iovlen;! void *msg_control;! socklen_t msg_controllen;! int msg_flags;}! msg_name and msg_namelen are used for unconnected UDP sockets to store a socket address and its length! msg_control and msg_controllen are used for optional ancillary data! TELE Lecture 10 Daemon processes and advanced I/O functions 21

22 Summary of flags!! msg_flags is used only by recvmsg. When recvmsg is called, the flags is copied into the msg_flags member and this value is used by the kernel to drive its receiving processing. This value is then updated based on the result of recvmsg! msg_flags is ignored by sendmsg since this function uses its argument flags! TELE Lecture 10 Daemon processes and advanced I/O functions 22

23 recvmsg! TELE Lecture 10 Daemon processes and advanced I/O functions 23

24 recvmsg (cont.)! TELE Lecture 10 Daemon processes and advanced I/O functions 24

25 Comparison of I/O functions! TELE Lecture 10 Daemon processes and advanced I/O functions 25

26 Ancillary data! struct cmsghdr {socklen_t cmsg_len; int cmsg_level; int cmsg_type; /* followed by char array */ }! TELE Lecture 10 Daemon processes and advanced I/O functions 26

27 Ancillary data (cont.)! TELE Lecture 10 Daemon processes and advanced I/O functions 27

28 Macros for ancillary data! TELE Lecture 10 Daemon processes and advanced I/O functions 28

29 Example for macros! TELE Lecture 10 Daemon processes and advanced I/O functions 29

30 Miscellaneous! Ways to find out how much data is queued! Use MSG_PEEK flag (MSG_DONTWAIT for nonblocking)! Use the FIONREAD command of ioctl! Handle sockets with standard I/O library! Use fdopen to convert a socket (descriptor) into a FILE pointer! Standard I/O uses three types of buffering! Fully buffered: I/O takes place only when the buffer is full, or the process calls fflush or exit! Line buffered: I/O takes place only when a new line is encountered, or the process calls fflush or exit! Unbuffered: I/O takes place each time a standard I/O output function is called! Most Unix implements standard I/O based on the following rules! Standard error is always unbuffered; standard input and output, and other streams are fully buffered, unless they refer to a terminal device, in which case they are line buffered.! TELE Lecture 10 Daemon processes and advanced I/O functions 30

Overview. Daemon processes and advanced I/O. Source: Chapters 13&14 of Stevens book

Overview. Daemon processes and advanced I/O. Source: Chapters 13&14 of Stevens book Overview Last Lecture Broadcast and multicast This Lecture Daemon processes and advanced I/O functions Source: Chapters 13&14 of Stevens book Next Lecture Unix domain protocols and non-blocking I/O Source:

More information

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions Overview Last Lecture Daemon processes and advanced I/O functions This Lecture Unix domain protocols and non-blocking I/O Source: Chapters 15&16&17 of Stevens book Unix domain sockets A way of performing

More information

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?! Overview!! Last Lecture!! Daemon processes and advanced I/O functions!! This Lecture!! VPN, NAT, DHCP!! Source: Chapters 19&22 of Comer s book!! Unix domain protocols and non-blocking I/O!! Source: Chapters

More information

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! Lecture 5 Overview! Last Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! This Lecture! Socket options! Source: Chapter 7 of Stevens book! Elementary UDP sockets! Source: Chapter 8 of Stevens

More information

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS Outline Operating Systems Socket basics Socket details Socket options Final notes Project 3 Sockets Socket Basics An end-point for a IP network connection what the application layer plugs into programmer

More information

Network programming(ii) Lenuta Alboaie

Network programming(ii) Lenuta Alboaie Network programming(ii) Lenuta Alboaie adria@info.uaic.ro 1 Content let s remember: iterative TCP client/server UDP client/server model I/O primitives Advanced programming aspects in Internet socket API

More information

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer. Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs

More information

Programming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Programming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 Programming Internet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 10/19/2015 CSCI 445 - Fall 2015 1 Acknowledgements Some pictures

More information

EEC-484/584 Computer Networks

EEC-484/584 Computer Networks EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer

More information

ISA 563: Fundamentals of Systems Programming

ISA 563: Fundamentals of Systems Programming ISA 563: Fundamentals of Systems Programming Advanced IO April 9, 2012 Non-blocking IO Data processing can be much faster than data access Waiting for IO to finish can be time consuming, and may not even

More information

Never Lose a Syslog Message

Never Lose a Syslog Message Never Lose a Syslog Message Alexander Bluhm bluhm@openbsd.org September 24, 2017 Agenda 1 Motivation 2 Starting Position 3 Local Improvements 4 Remote Logging 5 Conclusion Why reliable logging? system

More information

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014 Outline Distributed Computing Systems Sockets Socket basics Socket details (TCP and UDP) Socket options Final notes Socket Basics (1 of 2) An end-point for an Internet network connection what application

More information

CS4700/CS5700 Fundamentals of Computer Networking

CS4700/CS5700 Fundamentals of Computer Networking CS4700/CS5700 Fundamentals of Computer Networking Prof. Alan Mislove Lecture 3: Crash course in socket programming September 10th, 2009 Project 0 Goal: Familiarize you with socket programming in C Implement

More information

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)

More information

TELE 301 Lecture 8: Post

TELE 301 Lecture 8: Post Last Lecture System installation This Lecture Post installation Next Lecture Wireless networking Overview TELE 301 Lecture 8: Post 1 Post-configuration Create user accounts and environments Sort out the

More information

STUDY OF SOCKET PROGRAMMING

STUDY OF SOCKET PROGRAMMING STUDY OF SOCKET PROGRAMMING Sockets : An application programming interface(api) used for inter process communication. Sockets allow communication between two different processes on the same or different

More information

CS631 - Advanced Programming in the UNIX Environment. Dæmon processes, System Logging, Advanced I/O

CS631 - Advanced Programming in the UNIX Environment. Dæmon processes, System Logging, Advanced I/O CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Dæmon processes, System Logging, Advanced I/O Department of Computer Science Stevens Institute

More information

Contents. Part 1. Introduction and TCP/IP 1. Foreword Preface. xix. I ntroduction 31

Contents. Part 1. Introduction and TCP/IP 1. Foreword Preface. xix. I ntroduction 31 Foreword Preface Xvii xix Part 1. Introduction and TCP/IP 1 Chapter 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 Chapter 2. 2.1 2.2 2.3 I ntroduction I ntroduction 3 A Simple Daytime Client 6

More information

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction! Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction! This Lecture! Elementary TCP sockets! TCP Client-Server example! Source: Stevens book(chapters 4,5), Comer s book (Chapters 20, 21)!

More information

Elementary TCP Sockets

Elementary TCP Sockets Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel

More information

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket

More information

TCP: Three-way handshake

TCP: Three-way handshake Sockets in C 1 Sockets in C The slides by themselves will not be sufficient to learn how to write socket code. If you did not attend class, then you will want to review the relevant chapters in Kerrisk

More information

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line Operating Systems Lecture 06 System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line March 04, 2013 exec() Typically the exec system call is

More information

Group-A Assignment No. 6

Group-A Assignment No. 6 Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text

More information

CptS 360 (System Programming) Unit 17: Network IPC (Sockets)

CptS 360 (System Programming) Unit 17: Network IPC (Sockets) CptS 360 (System Programming) Unit 17: Network IPC (Sockets) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation Processes need to talk to each other

More information

Standards / Extensions C or C++ Dependencies POSIX.1 XPG4 XPG4.2 Single UNIX Specification, Version 3

Standards / Extensions C or C++ Dependencies POSIX.1 XPG4 XPG4.2 Single UNIX Specification, Version 3 read() Read From a File or Socket z/os V1R10.0 XL C/C++ Run-Time Library Reference SA22-7821-10 Standards Standards / Extensions C or C++ Dependencies POSIX.1 XPG4 XPG4.2 Single UNIX Specification, Version

More information

What could be done in the kernel to make strace happy

What could be done in the kernel to make strace happy What could be done in the kernel to make strace happy Dmitry Levin Linux Plumbers Conference 2018 Problems [2/21] 1 There is no kernel API to find out whether the tracee is entering or exiting syscall.

More information

Programming with TCP/IP. Ram Dantu

Programming with TCP/IP. Ram Dantu 1 Programming with TCP/IP Ram Dantu 2 Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a

More information

Interprocess Communication. Interprocess Communication

Interprocess Communication. Interprocess Communication Interprocess Communication Interprocess Communication The original UNIX systems had pipes as the only interprocess communication method. An improved interprocess communications interface was designed for

More information

Advanced Unix Concepts. Satyajit Rai

Advanced Unix Concepts. Satyajit Rai Advanced Unix Concepts Advanced Unix Concepts Satyajit Rai March 17, 2003 March 22, 2003 KReSIT, IIT Bombay 1 Contents Contents Advanced Unix Concepts.......... 1 Contents.................. 2 Process Creation..............

More information

Expires: April 20, 2006 M. Tuexen Muenster Univ. of Applied Sciences T. Dreibholz University of Duisburg-Essen October 17, 2005

Expires: April 20, 2006 M. Tuexen Muenster Univ. of Applied Sciences T. Dreibholz University of Duisburg-Essen October 17, 2005 Network Working Group Internet-Draft Expires: April 20, 2006 A. Silverton Q. Xie Motorola M. Tuexen Muenster Univ. of Applied Sciences T. Dreibholz University of Duisburg-Essen October 17, 2005 Status

More information

CS 351 Week 15. Course Review

CS 351 Week 15. Course Review CS 351 Week 15 Course Review Objectives: 1. To review the contents from different weeks. 2. To have a complete understanding of important concepts from different weeks. Concepts: 1. Important Concepts

More information

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers Networked Applications: Sockets CS 375: Computer Networks Spring 2009 Thomas Bressoud 1 Goals of Todayʼs Lecture Client-server paradigm End systems Clients and servers Sockets and Network Programming Socket

More information

UNIX Network Programming

UNIX Network Programming UNIX Network Programming The Sockets Networking API Volume 1 Third Edition W. Richard Stevens Bill Fenner Andrew M. Rudoff AAddison-Wesley Boston San Francisco New York Toronto Montreal London Munich Paris

More information

Ken French HELP Session 1 CS4514

Ken French HELP Session 1 CS4514 Ken French HELP Session 1 CS4514 CS4514 We expect that you have had a programming course similar to 2005 before coming into this class. Programs will be done in C or C++ We also expect that you will have

More information

NETWORK PROGRAMMING. Ipv4 and Ipv6 interoperability

NETWORK PROGRAMMING. Ipv4 and Ipv6 interoperability NETWORK PROGRAMMING UNIT V ADVANCED SOCKETS Ipv4 and Ipv6 interoperability threaded servers thread creation and termination TCP echo server using threads Mutexes condition variables raw sockets raw socket

More information

Oral. Total. Dated Sign (2) (5) (3) (2)

Oral. Total. Dated Sign (2) (5) (3) (2) R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer

More information

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

CMPS 105 Systems Programming. Prof. Darrell Long E2.371 + CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared

More information

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C 1 CSIS0234A Computer and Communication Networks Socket Programming in C References Beej's Guide to Network Programming Official homepage: http://beej.us/guide/bgnet/ Local mirror http://www.cs.hku.hk/~c0234a/bgnet/

More information

Multiservice servers. Stefan D. Bruda. Winter 2018

Multiservice servers. Stefan D. Bruda. Winter 2018 Multiservice servers Stefan D. Bruda Winter 2018 MULTISERVICE SERVERS Why? Because it sounds like fun Because we may need it E.g., a database server might receive requests from clients, but also from other

More information

CLIENT-SIDE PROGRAMMING

CLIENT-SIDE PROGRAMMING CLIENT-SIDE PROGRAMMING George Porter Apr 11, 2018 ATTRIBUTION These slides are released under an Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Creative Commons license These slides

More information

Tutorial on Socket Programming

Tutorial on Socket Programming Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Hao Wang (Slides are mainly from Seyed Hossein Mortazavi, Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client-server

More information

FastFlow: targeting distributed systems Massimo Torquati

FastFlow: targeting distributed systems Massimo Torquati FastFlow: targeting distributed systems Massimo Torquati May 17 th, 2012 torquati@di.unipi.it http://www.di.unipi.it/~torquati FastFlow node FastFlow's implementation is based on the concept of node (ff_node

More information

Delayline A Wide-Area Network Emulation Tool

Delayline A Wide-Area Network Emulation Tool Delayline A Wide-Area Network Emulation Tool David B Ingham Graham D Parrington Department of Computing Science, University of Newcastle, Newcastle upon Tyne, NE1 7RU UK Distributed applications that communicate

More information

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani Titolo presentazione Piattaforme Software per la Rete sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Outline 1) Introduction to Sockets 2) UDP communication 3) TCP communication 4) RAW

More information

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Ports under 1024 are often considered special, and usually require special OS privileges to use. 1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's

More information

CSE 124 Discussion Section Sockets Programming 10/10/17

CSE 124 Discussion Section Sockets Programming 10/10/17 CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code

More information

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University A Socket Example & George Mason University Everything is a file descriptor Most socket system calls operate on file descriptors Server - Quick view socket() bind() listen() accept() send(), recv() close()

More information

CSE 333 Section 8 - Client-Side Networking

CSE 333 Section 8 - Client-Side Networking CSE 333 Section 8 - Client-Side Networking Welcome back to section! We re glad that you re here :) Networking Quick Review What are the following protocols used for? (bonus: what layer of the networking

More information

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation Lecture 2 Outline Wireshark Project 1 posted, due in a week Lab from a different textbook Work through the lab and answer questions at the end Chapter 1 - Foundation 1.1 Applications 1.2 Requirements 1.3

More information

Introduction! Overview! Signal-driven I/O for Sockets! Two different UDP servers!

Introduction! Overview! Signal-driven I/O for Sockets! Two different UDP servers! Overview Last Lecture Advanced UDP sockets and threads Source: Chapters 22&26 of Stevens book This Lecture Signal-driven I/O, Raw sockets Source: Chapters 25&28&29 of Stevens book Next Lecture WSN and

More information

Lenuta Alboaie Computer Networks

Lenuta Alboaie Computer Networks Network Programming - OOB - Lenuta Alboaie adria@info.uaic.ro 1 Content Sending and receiving data using out-of-band 2 Sending and receiving data using out-ofband The idea: during a connection, when data

More information

Sistemas Operativos /2016 Support Document N o 1. Files, Pipes, FIFOs, I/O Redirection, and Unix Sockets

Sistemas Operativos /2016 Support Document N o 1. Files, Pipes, FIFOs, I/O Redirection, and Unix Sockets Universidade de Coimbra Departamento de Engenharia Electrotécnica e de Computadores Sistemas Operativos - 2015/2016 Support Document N o 1 Files, Pipes, FIFOs, I/O Redirection, and Unix Sockets 1 Objectives

More information

Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현

Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현 Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현 4.1 Introduction A Time line of the typical scenario that takes place between a TCP client and server. Describes the

More information

Networked Applications: Sockets. End System: Computer on the Net

Networked Applications: Sockets. End System: Computer on the Net Networked Applications: Sockets Topics Programmer s view of the Internet Sockets interface End System: Computer on the Net Internet Also known as a host 2 Page 1 Clients and Servers Client program Running

More information

UDP CONNECT TO A SERVER

UDP CONNECT TO A SERVER UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server

More information

SOCKETS: INTRODUCTION

SOCKETS: INTRODUCTION SOCKETS: INTRODUCTION Sockets are a method of IPC that allow data to be exchanged between applications, either on the same host (computer) or on different hosts connected by a network. The first widespread

More information

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements Announcements CS 5565 Network Architecture and Protocols Lecture 5 Godmar Back Problem Set 1 due Feb 17 Project 1 handed out shortly 2 Layer The Layer Let s look at some s (in keeping with top-down) architectures:

More information

UNIX Sockets. COS 461 Precept 1

UNIX Sockets. COS 461 Precept 1 UNIX Sockets COS 461 Precept 1 Socket and Process Communica;on application layer User Process Socket transport layer (TCP/UDP) OS network stack network layer (IP) link layer (e.g. ethernet) Internet Internet

More information

Chapter 3: Client-Server Paradigm and Middleware

Chapter 3: Client-Server Paradigm and Middleware 1 Chapter 3: Client-Server Paradigm and Middleware In order to overcome the heterogeneity of hardware and software in distributed systems, we need a software layer on top of them, so that heterogeneity

More information

IPv4 and ipv6 INTEROPERABILITY

IPv4 and ipv6 INTEROPERABILITY IT2351-NPM/UNIT-4/ 1 IPv4 and ipv6 INTEROPERABILITY Till the time, IPv6 is established all over the world, there is a need for one to host dual stacks that is both IPv4 and IPv6 are running concurrently

More information

Interprocess Communication

Interprocess Communication Interprocess Communication B.Ramamurthy CSE421 11/5/02 B.R 1 Topics Pipes (process level) Sockets (OS level) Distributed System Methods (Java s) Remote Method Invocation (PL Level) Other communication

More information

Socket programming in C

Socket programming in C Socket programming in C Sven Gestegård Robertz September 2017 Abstract A socket is an endpoint of a communication channel or connection, and can be either local or over the network.

More information

Any of the descriptors in the set {1, 4} have an exception condition pending

Any of the descriptors in the set {1, 4} have an exception condition pending Page 1 of 6 6.3 select Function This function allows the process to instruct the kernel to wait for any one of multiple events to occur and to wake up the process only when one or more of these events

More information

UNIX System Administration

UNIX System Administration $!... 14:13 $$... 14:13.netrc...12:27-28 /etc/fstab... 6:25 /etc/hosts.equiv... 8:23 /etc/inittab Entries... 4:8 /etc/netmasks... 8:22 /etc/shells... 12:25 /home... 6:69 /tmp...6:61-67 /usr... 6:70 /var...

More information

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks #In the name of Allah Computer Engineering Department Sharif University of Technology CE443- Computer Networks Socket Programming Acknowledgments: Lecture slides are from Computer networks course thought

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name

More information

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name

More information

LINX(7) manual page. Name. Synopsis. Description. Linx Concepts. LINX(7) manual page. linx - LINX inter-process communication protocol

LINX(7) manual page. Name. Synopsis. Description. Linx Concepts. LINX(7) manual page. linx - LINX inter-process communication protocol LINX(7) manual page Name linx - LINX inter-process communication protocol Synopsis #include #include #include #include #include #include

More information

The User Datagram Protocol

The User Datagram Protocol The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.

More information

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 Programming Ethernet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 9/14/2015 CSCI 445 Fall 2015 1 Acknowledgements Some pictures

More information

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags Outline SWE 545 Socket Options POSIX name/address conversion Out-of-Band Data Advanced Socket Programming 2 Socket Options Various attributes that are used to determine the behavior of sockets Setting

More information

10. I/O System Library

10. I/O System Library 10. I/O System Library Header File #include // Found in C:\Nburn\include General File Descriptor Functions close --- Close open file descriptors read --- Read data from a file descriptor ReadWithTimeout

More information

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013 Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different

More information

CMPSC 311 Such Final Very Exam

CMPSC 311 Such Final Very Exam Section: 2:30 3:35 Name: CMPSC 311 Such Final Very Exam May 5, 2014 Closed book, closed neighbor, no electronic tools or additional papers. You may not share or discuss exam questions with anyone. This

More information

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018 CS 43: Computer Networks 05: Socket Programming September 12-14, 2018 Reading Quiz Lecture 5/6 - Slide 2 Socket Programming Adapted from: Donahoo, Michael J., and Kenneth L. Calvert. TCP/IP sockets in

More information

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1 CSMC 412 Computer Networks Prof. Ashok K Agrawala 2015 Ashok Agrawala Set 2 September 15 CMSC417 Set 2 1 Contents Client-server paradigm End systems Clients and servers Sockets Socket abstraction Socket

More information

SCTP in Go. arxiv: v1 [cs.ni] 20 Nov 2017

SCTP in Go. arxiv: v1 [cs.ni] 20 Nov 2017 1 SCTP in Go Olivier Van Acker Department of Computer Science and Information Systems Birkbeck University of London London, United Kingdom Email: ovanac01@mail.bbk.ac.uk arxiv:1711.07224v1 [cs.ni] 20 Nov

More information

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Sockets Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Internet Connections (1) Connection Clients and servers communicate by sending streams of

More information

Operating Systems. Review ENCE 360

Operating Systems. Review ENCE 360 Operating Systems Review ENCE 360 High level Concepts What are three conceptual pieces fundamental to operating systems? High level Concepts What are three conceptual pieces fundamental to operating systems?

More information

Introduction to Network Programming in C/C++

Introduction to Network Programming in C/C++ Introduction to Network Programming in C/C++ 10.09.2009 Varun SINGH, Based on the slides by Joerg Ott and Carsten Bormann 1 Starting Point IDE Unix/Linux available in the department

More information

Processes. CS3026 Operating Systems Lecture 05

Processes. CS3026 Operating Systems Lecture 05 Processes CS3026 Operating Systems Lecture 05 Dispatcher Admit Ready Queue Dispatch Processor Release Timeout or Yield Event Occurs Blocked Queue Event Wait Implementation: Using one Ready and one Blocked

More information

UNIX Kernel. UNIX History

UNIX Kernel. UNIX History UNIX History UNIX Kernel 1965-1969 Bell Labs participates in the Multics project. 1969 Ken Thomson develops the first UNIX version in assembly for an DEC PDP-7 1973 Dennis Ritchie helps to rewrite UNIX

More information

Client Server Computing

Client Server Computing Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a remote computer. Instead, two application

More information

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes. Unix-Linux 2 fork( ) system call is successful parent suspended child created fork( ) returns child pid to parent fork( ) returns zero value to child; zero is the pid of the swapper/scheduler process both

More information

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS outline network programming BSD/POSIX Socket API RPC systems object-oriented bridges CORBA DCOM RMI WebServices WSDL/SOAP XML-RPC REST network

More information

Tcpdump. For this exercise you must again be root. Login and obtain root privileges: Note that we use three computers for this exercise.

Tcpdump. For this exercise you must again be root. Login and obtain root privileges: Note that we use three computers for this exercise. 1 For this exercise you must again be root. Login and obtain root privileges: sudo su Note that we use three computers for this exercise. C S H 2 Create an account on the server that can be used from the

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 Programming Ethernet with Socket API Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806 9/14/2016 CSCI 445 Fall 2016 1 Acknowledgements Some pictures

More information

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC The Embedded I/O Company TIP700-SW-82 Linux Device Driver Digital Output 24V DC Version 1.2.x User Manual Issue 1.2.1 February 2009 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 Phone: +49 (0) 4101 4058 0 25469

More information

Socket Programming for TCP and UDP

Socket Programming for TCP and UDP CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming

More information

A Client-Server Exchange

A Client-Server Exchange Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends

More information

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

CSC209H Lecture 9. Dan Zingaro. March 11, 2015 CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess

More information

INTRODUCTION TO THE UNIX FILE SYSTEM 1)

INTRODUCTION TO THE UNIX FILE SYSTEM 1) INTRODUCTION TO THE UNIX FILE SYSTEM 1) 1 FILE SHARING Unix supports the sharing of open files between different processes. We'll examine the data structures used by the kernel for all I/0. Three data

More information

CS 640: Computer Networking

CS 640: Computer Networking CS 640: Computer Networking Yu-Chi Lai Lecture 3 Network Programming Topics Client-server model Sockets interface Socket primitives Example code for echoclient and echoserver Debugging With GDB Programming

More information

SOCKET. Valerio Di Valerio

SOCKET. Valerio Di Valerio SOCKET Valerio Di Valerio The Problem! Communication between computers connected to a network Network Network applications! A set of processes distributed over a network that communicate via messages!

More information

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005 Followup symbolic link (soft link): pathname, can be across file systems, replacement of file will be active on all symbolic links, consumes at least an inode. hard link: pointers to an inode, only in

More information

Tunneling. Encapsulation and Tunneling. Performance implications of data transmission on high speed network devices

Tunneling. Encapsulation and Tunneling. Performance implications of data transmission on high speed network devices Encapsulation and Tunneling slide 1 Tunneling slide 2 encapsulation describes the process of placing an IP datagram inside a network packet or frame encapsulation refers to how the network interface uses

More information

Introduction for SPI mapping Service Discovery Interoperability Testing. 20, Sep PWG Fumio Nagasaka

Introduction for SPI mapping Service Discovery Interoperability Testing. 20, Sep PWG Fumio Nagasaka Introduction for SPI mapping Service Discovery Interoperability Testing 20, Sep. 1999 1394 PWG Fumio Nagasaka Open Issues are related to each other requires authorized API specification Interoperability

More information