Network Programming CSC- 341

Slides:



Advertisements
Similar presentations
File and I/O system calls int open(const char* path, int flags, mode_t modes) int creat(const char *path, mode_t mode) ssize_t read(int fd, void *buf,
Advertisements

Ipv4 Socket Address Structure struct in_addr { in_addr_t s_addr; /* 32-bit IPv4 address */ /* network byte ordered */ }; struct sockaddr_in { uint8_t sin_len;
Programming with UDP – I Covered Subjects: IPv4 Socket Address Structure Byte Ordering Functions Address Access/Conversion Functions Functions: 1.socket()
1 Files and Directories Hua LiSystems ProgrammingCS2690Files and Directories.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved Processes Figure 1-5.
Ways to read data from disk to memory Tan Li. read, write read, write -- low level file access, it's an operation between two file discriptors. SYNOPSIS.
Sockets Programming Introduction © Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
1 Advanced programming in UNIX 1 File I/O Hua LiSystems ProgrammingCS2690File I/O.
CS 311 – Lecture 10 Outline Review open() and close() Difference between fopen() and open() File management system calls – read() – write() – lseek() –
Files and Directories Hua LiSystems ProgrammingCS2690Files and Directories Spring 2003Page 1 of 60.
I/O April 16, 2002 Topics Files Unix I/O Standard I/O Reading: (Beta) or (New) Problems: 12.9 (Beta) or 12.4 (New) class24.ppt
Lecture 10 Overview. Network API Application Programming Interface – Services that provide the interface between application and protocol software often.
CS 311 – Lecture 12 Outline File management system calls Stat() Directory Information  Opendir()  Readdir()  Closedir() Truncate() and remove() Lecture.
NCHU System & Network Lab Lab 13 File I/O & Standard I/O.
POSIX: Files Introduction to Operating Systems: Discussion 1 Read Solaris System Interface Guide: Ch. 5.1 Basic File I/O.
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
Input and Output Topics I/O hardware Unix file abstraction Robust I/O File sharing io.ppt CS 105 “Tour of the Black Holes of Computing”
File System Review bottomupcs.com J. Kubiatowicz, UC Berkeley.
Operating Systems Recitation 1, March th, 2002.
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.
Remote Shell CS230 Project #4 Assigned : Due date :
UNIX Files File organization and a few primitives.
Lecture 15 Overview.
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.
Files and Directories File types stat functions for file information
Socket Programming Lab 1 1CS Computer Networks.
Lecture 3 Introduction to Unix Systems Programming: Unix File I/O System Calls.
Interprocess Communication Anonymous Pipes Named Pipes (FIFOs) popen() / pclose()
Today’s topic Access and manipulate meta data for files –File type, ownership, access permissions, access time, etc How to determine if a file is not there?
CSCI 330 UNIX and Network Programming Unit VII: I/O Management I.
Today’s topic: UDP Reliable communication over UDP.
Programming with UNIX File Systems (Chap 3, 4. in the book “Advanced Programming in the UNIX Environment”) Acknowledgement : Prof. Y. Moon at Kangwon Nat’l.
Review: –Concurrent server and multiplexed server How they work? Which one is better?
Sockets Introduction Socket address structures Value-result arguments
CMPT 471 Networking II Network Programming © Janice Regan,
UNIX Network Programming1 Chapter 13. Advanced I / O Functions.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
Library Functions The UNIX system provides a large number of C functions as libraries. Some of these implement frequently used operations, while others.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Virtual Filesystem.
CSCI 330 UNIX and Network Programming Unit VIII: I/O Management II.
1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level connection.Establishing.
OS interface: file and I/O system calls File operations in C/C++? –fopen(), fread(), fwrite(), fclose(), fseek() in C f.open(…), f.close(…) in C++ I/O.
File Subsystem in Linux by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
CSC 271 – Software I: Utilities and Internals An Introduction to File I/O in Linux Credited to Dr. Robert Siegfried and Beginning Linux Programming by.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
File table: a list of opened files Each entry contains: – Index: file descriptors – Pointer to the file in memory – Access mode File descriptor is a positive.
Files in UNIX u UNIX deals with two different classes of files:  Special Files  Regular Files u Regular files are just ordinary data files on disk -
Netprog: TCP Sockets1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level.
File System Design David E. Culler CS162 – Operating Systems and Systems Programming Lecture 23 October 22, 2014 Reading: A&D a HW 4 out Proj 2 out.
Andrew Hanushevsky: Basic I/O API’s
Lecture 31: Introduction to File System
Network Programming CSC- 341
UNIX FILES
Operating System Hebrew University Spring 2004
Network Programming CSC- 341
An overview of the kernel structure
Recitation 9 Greg Reshko
Lecture 11 Overview.
TCP Sockets Programming
“The course that gives CMU its Zip!”
File Structure Related system calls
Network Programming CSC- 341
IPC Prof. Ikjun Yeom TA – Hoyoun
Programming with UNIX File Systems (Chap 3, 4
Advanced I/O Functions
Presentation transcript:

Network Programming CSC- 341 Instructor: Junaid Tariq, Lecturer, Department of Computer Science

13 Lecture Network Programming

3.9 readn, writen, and realine Functions #include “unp.h” ssize_t readn(int filedes, void *buff, size_t nbytes); ssize_t writen(int filedes, const void *buff, size_t nbytes); ssize_t readline(int filedes, void *buff, size_t maxline); All return: number of bytes read or written, -1 on error

Readn()

writen

readline

3.10 Isfdtype function Test a Descriptor to see if it is of a specified type historically : fstat function used ==> testing the returned value st_mode value using one of the S_IFxxx macro. #include <sys/stat.h> int isfdtype(int fd, int fdtype); /* return:1 if descriptor of specified type, 0 if not, -1 on error */ /* To test for a socket, fdtype is S_IFSOCK.*/

#ifndef S_IFSOCK #error S_IFSOCK not defined #endif int isfdtype(int fd, int fdtype) { struct stat buf; if(fstat (fd, &buf) < 0) return (-1); if((buf.st_mode & S_IFMT) == fdtype) return (1); else return (0); }

st_mode field The following flags are defined for the st_mode field: S_IFMT bit mask for the file type bit fields S_IFSOCK socket S_IFLNK symbolic link S_IFREG regular file S_IFBLK block device S_IFDIR directory S_IFCHR character device S_IFIFO FIFO