Advanced I/O Functions

Slides:



Advertisements
Similar presentations
Nonblocking I/O Blocking vs. non-blocking I/O
Advertisements

TELE 402 Lecture 11: Advanced UDP… 1 by Dr Z. Huang Overview Last Lecture –Nonblocking I/O and ioctl operations –Source: Chapter 16 & 17 of Stevens’ book.
Sockets CS 3516 – Computer Networks. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Distributed Computing Systems Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Computer Networks Sockets.
Multimedia Networking Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
Sockets IMGD Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
1 Advanced I/O Computer Network Programming. 2 Regarding Project1 –Use RCS to store different revisions of your programs –this is a requirement! –you.
Additional API functions and data-structures A look at how some information from lower-layers of the TCP/IP protocol stack could be accessed.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Raw Sockets (+ other) UNPv1 - Stevens, Fenner, Rudoff Linux Socket Programming - Walton.
Operating Systems Sockets. Outline F Socket basics F TCP sockets F Socket details F Socket options F Final notes F Project 3.
Lecture 8 UDP Sockets & I/O Multiplexing
Sockets CIS 370 Fall 2009, UMassD. Introduction  Sockets provide a simple programming interface which is consistent for processes on the same machine.
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
1 Introduction to Raw Sockets 2 IP address Port address MAC address TCP/IP Stack 67 Bootp DHCP OSPF protocol frame type UDP Port # TCP Port.
ECE 4110 – Internetwork Programming Client-Server Model.
Sockets and intro to IO multiplexing. Goals We are going to study sockets programming as means to introduce IO multiplexing problem. We will revisit socket.
Nonblocking I/O Blocking vs. non-blocking I/O Nonblocking input, output, accept, and connect Readings –UNP Ch16 1.
Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we.
TELE 402 Lecture 10: Unix domain … 1 Overview Last Lecture –Daemon processes and advanced I/O functions This Lecture –Unix domain protocols and non-blocking.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
Advanced Sockets API-II Vinayak Jagtap
Socket I/O 백 일 우
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
TELE 402 Lecture 9: Daemon … 1 by Dr Z. Huang Overview Last Lecture –Broadcast and multicast This Lecture –Daemon processes and advanced I/O functions.
Programming with UDP – II Covered Subjects: Creating UDP sockets Client Server Sending data Receiving data Connected mode.
Today’s topic: UDP Reliable communication over UDP.
Review: –Concurrent server and multiplexed server How they work? Which one is better?
UDP Sockets Chap 8, 14, 22. Elementary UDP Sockets Chap 8.
Sockets Introduction Socket address structures Value-result arguments
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
CMPT 471 Networking II Network Programming © Janice Regan,
UNIX Network Programming1 Chapter 13. Advanced I / O Functions.
Read() recv() connection establishment Server (connection-oriented protocol) blocks until connection from client Client socket() bind() listen() accept()
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Sockets Intro to Network Programming. Before the internet... Early computers were entirely isolated No Internet No network No model No external communications.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
1 UDP Sockets Programming Creating UDP sockets.Creating UDP sockets. –Client –Server Sending data.Sending data. Receiving data.Receiving data. Connected.
Sockets API Developing Applications using the Sockets API.
Socket Abstraction and Interprocess Communication
Socket Option.
Operating Systems Sockets ENCE 360.
Elementary UDP Sockets
Network Programming CSC- 341
Week 13 - Friday CS222.
Socket Programming in C
Interprocess Communication
Introduction to Socket Programming
UDP Sockets Programming
Socket Abstraction and Interprocess Communication
User Datagram Protocol (UDP)
Socket Programming in C
Lecture 11 Overview.
Socket 程式設計.
TCP/IP Socket Programming in C
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Sockets.
Socket Programming with UDP
Socket options: a summary
Advanced UNIX programming
Presentation transcript:

Advanced I/O Functions Socket timeouts recv and send functions readv and writev functions recvmsg and sendmsg functions Ancillary data T/TCP: TCP for transactions

Socket Timeouts Call alarm which generates SIGALRM before calling socket functions Block waiting for I/O in select which has a time limit built in Set SO_RCVTIMEO and SO_SNDTIMEO socket options by setsockopt

recv and send Functions ~ read and write #include <sys/socket.h> 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 flags Description recv send MSG_DONTROUTE bypass routing table lookup X MSG_DONTWAIT only this operation is nonblocking MSG_OOB send or receive out-of-band data MSG_PEEK peek at incoming message MSG_WAITALL wait for all the data

readv and writev Functions scatter read and gather write ~ read and write #include <sys/uio.h> ssize_t readv (int filedes, const struct iovec *iov, int iovcnt); ssize_t writev (int filedes, const struct iovec *iov, int iovcnt); both return: number of bytes read or written, -1 on error *iov: a pointer to an arrary of iovec structure struct iovec { void *iov_base; /* starting address of buffer */ size_t iov_len; /* size of buffer */ };

recvmsg and sendmsg Functions the most general socket I/O functions #include <sys/socket.h> 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; /* protocol address */ socklen_t msg_namelen; /* size of protocol address */ struct iovec *msg_iov; /* scatter/gather array */ size_t msg_iovlen; /* # elements in msg_iov */ void *msg_control; /* ancillary data; must be aligned for a cmsghdr structure */ socklen_t msg_controllen; /* length of ancillary data */ int msg_flags; /* flags returned by recvmsg ( ) */ };

Summary of I/O Flags by Various I/O Functions Examined by: send flags sendto flags sendmsg flags recv flags recvfrom flags recvmsg flags Returned by: recvmsg msg_flags MSG_DONTROUTE MSG_DONTWAIT MSG_PEEK MSG_WAITALL X MSG_EOR MSG_OOB MSG_BCAST MSG_MCAST MSG_TRUNC MSG_CTRUNC

msghdr When recvmsg Returns Sockaddr{} 16,AF_INET,2000 198.69.10.2 msghdr{} cmsg_len 16 cmsg_level IPPROTO_IP cmsg_type IP_RECVDSTADDR 206.62.226.35

Comparison of Five Groups of I/O Functions

Ancillary Data (Control Info)

T/TCP: TCP for Transactions avoid three-way handshake between hosts that have communicated with each other recently 3 segments for T/TCP, compared to 10 for TCP and 2 for UDP