chat.h #ifndef _CHAT_H #define _CHAT_H #define LBUFFSIZE 128 #define CBUFFSIZE 331
|
|
- Della McDaniel
- 6 years ago
- Views:
Transcription
1 chat.h #ifndef _CHAT_H #define _CHAT_H #define LBUFFSIZE 128 #define CBUFFSIZE 331 #define INCRSLOT(V) { \ ++(V) ; \ if ((V) >= CBUFFSIZE) \ (V) = 0 ; \ enum Lstates {UNUSED, MESSAGE ; struct linebuff { enum Lstates status; / status of this linebuffer / int created ; / Time (seconds since 1970?) entry was made / int size ; / number of characters used in buffer / char buff[lbuffsize] ; / characters of the buffer / ; struct chatbuff { int nextslot ; / Index of nextslot to use / struct linebuff buff[cbuffsize] ; ; struct ptgenericarg { struct chatbuff G ; / Pointer to the global chatbuff / int sock ; / File Descriptor for socket / ; / prototypes for pthread_create / void InputFromUser(void ) ; void OutputToUser(void ) ; void InputRecept(void ) ; void OutputRecept(void ) ;
2 Main.c / Main routine... Starts the child threads / #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <pthread.h> #ifndef CHATINPORT #define CHATINPORT 7331 #ifndef CHATOUTPORT #define CHATOUTPORT 8331 int main(int argc, char argv[]) { int in_recept, out_recept ; struct sockaddr_in servaddr ; pthread_attr_t attribthread ; pthread_t inthread, outthread ; struct ptgenericarg inarg ; struct ptgenericarg outarg ; void newdata ; struct chatbuff G ; int i ; (void) pthread_attr_init(&attribthread) ; / Open the two sockets before creating the receptionist Pthreads This is the most likely thing to fail / if (((in_recept = socket(af_inet, SOCK_STREAM, 0)) < 0) ((out_recept = socket(af_inet, SOCK_STREAM, 0)) < 0)) { fputs("unable to create sockets\n", stderr) ; / Now this is unlikely to happen / servaddr.sin_family = AF_INET ; servaddr.sin_addr.s_addr = INADDR_ANY ; servaddr.sin_port = htons(chatinport) ; if (bind(in_recept, (struct sockaddr ) &servaddr, sizeof(struct sockaddr_in))) { fprintf(stderr, "Unable to bind to port %d\n", CHATINPORT) ; if (errno == EADDRINUSE) fputs("check if another server is still running\n\n" "If a server recently terminated, wait before restarting.\n", stderr) ; (void) listen(in_recept, SOMAXCONN) ; servaddr.sin_port = htons(chatoutport) ;
3 if (bind(out_recept, (struct sockaddr ) &servaddr, sizeof(struct sockaddr_in))) { fprintf(stderr, "Unable to bind to port %d\n", CHATOUTPORT) ; if (errno == EADDRINUSE) fputs("check if another server is still running\n\n" "If a server recently terminated, wait before restarting.\n", stderr) ; (void) listen(out_recept, SOMAXCONN) ; fprintf(stdout, "Reading connections -> %5d\n", CHATINPORT) ; fprintf(stdout, "Writing connections -> %5d\n", CHATOUTPORT) ; / Initialize chat buffer / if ((G = malloc(sizeof(struct chatbuff))) == NULL) { G->nextSlot = 0 ; for (i=0; i<cbuffsize; ++i) { G->buff[i].status = UNUSED ; G->buff[i].size = 0 ; inarg = (struct ptgenericarg )newdata ; inarg->sock = in_recept ; inarg->g = G ; if (pthread_create(&inthread, &attribthread, InputRecept, newdata)) { perror("pthread_create InputRecept") ; outarg = (struct ptgenericarg )newdata ; outarg->sock = out_recept ; outarg->g = G ; if (pthread_create(&outthread, &attribthread, OutputRecept, newdata)) { perror("pthread_create OutputRecept") ; pthread_join(inthread, (void )NULL) ; pthread_join(outthread, (void )NULL) ;
4 InputRecept.c / Input Receptionist This is the thread routine for starting new output threads / #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <pthread.h> void InputRecept(void ptargs) { struct chatbuff G ; pthread_attr_t attribthread ; (void) pthread_attr_init(&attribthread) ; (void) pthread_attr_setdetachstate(&attribthread, PTHREAD_CREATE_DETACHED) ; mysock = ((struct ptgenericarg )ptargs) -> sock ; G = ((struct ptgenericarg )ptargs) -> G ; while (1) { void newdata ; int clntsize ; int newclient ; struct sockaddr_in clntaddr; pthread_t newthread ; struct ptgenericarg newthreadargs ; char chattername ; clntsize = sizeof(struct sockaddr_in) ; newclient = accept(mysock, (struct sockaddr )&clntaddr, &clntsize) ; if (newclient<0) { perror("accept") ; / Shutting down the write side causes telnet to terminate / / (void) shutdown(newclient, SHUT_WR) ; / newthreadargs = (struct ptgenericarg )newdata ; newthreadargs->g = G ; newthreadargs->sock = newclient ; if (pthread_create(&newthread, &attribthread, InputFromUser, newdata)) { perror("pthread_create") ; return ((void )NULL) ;
5 OutputRecept.c / Output Receptionist This is the thread routine for starting new output threads / #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <pthread.h> void OutputRecept(void ptargs) { struct chatbuff G ; pthread_attr_t attribthread ; (void) pthread_attr_init(&attribthread) ; (void) pthread_attr_setdetachstate(&attribthread, PTHREAD_CREATE_DETACHED) ; mysock = ((struct ptgenericarg )ptargs) -> sock ; G = ((struct ptgenericarg )ptargs) -> G ; while (1) { void newdata ; int clntsize ; int newclient ; struct sockaddr_in clntaddr; pthread_t newthread ; struct ptgenericarg newthreadargs ; clntsize = sizeof(struct sockaddr_in) ; newclient = accept(mysock, (struct sockaddr )&clntaddr, &clntsize) ; if (newclient<0) { perror("accept") ; (void) shutdown(newclient, SHUT_RD) ; newthreadargs = (struct ptgenericarg )newdata ; newthreadargs->g = G ; newthreadargs->sock = newclient ; if (pthread_create(&newthread, &attribthread, OutputToUser, newdata)) { perror("pthread_create") ; return ((void )NULL) ;
6 InputFromUser.c / This is the thread routine for taking input from the user and placing it into the chat buffer. / #include <stdio.h> #include <strings.h> void AddToChatBuffer(struct chatbuff G, struct linebuff pmylinebuff){ int myslot ; myslot = G->nextSlot ; INCRSLOT(&G->nextSlot) ; bcopy((void )pmylinebuff,(void )&G->buff[mySlot],sizeof(struct linebuff)); void InputFromUser(void ptargs) { struct chatbuff volatile G ; struct linebuff mylinebuff ; struct timeval present ; int userinputsize ; int stillconnected ; FILE sockin ; mysock = ((struct ptgenericarg )ptargs) -> sock ; G = ((struct ptgenericarg )ptargs) -> G ; if ((sockin = fdopen(mysock, "r")) == (FILE )NULL) { perror("fdopen") ; pthread_exit((void )NULL) ; stillconnected = 1 ; mylinebuff.status = MESSAGE ; while (stillconnected) { int nextc = 0 ; mylinebuff.size = 0 ; while (stillconnected && mylinebuff.size<cbuffsize-1 && nextc!= '\n') { if ((nextc=fgetc(sockin))!= EOF) { mylinebuff.buff[mylinebuff.size] = nextc ; ++mylinebuff.size ; else stillconnected = 0 ; if (stillconnected) { gettimeofday(&present, (struct timezone )NULL) ; mylinebuff.created = present.tv_sec ; #ifdef DEBUG mylinebuff.buff[mylinebuff.size] = '\0'; printf("new line %s", mylinebuff.size, mylinebuff.buff) ; AddToChatBuffer(G, &mylinebuff) ; return ((void )NULL) ;
7 OutputToUser.c / This is the thread routine for removing items from the chat buffer and sending them to the user. / #include <strings.h> #include <stdio.h> void OutputToUser(void ptargs) { struct chatbuff volatile G ; struct linebuff mylinebuff ; int mynextslot ; int stillconnected ; FILE sockout ; mysock = ((struct ptgenericarg )ptargs) -> sock ; G = ((struct ptgenericarg )ptargs) -> G ; stillconnected = 1 ; mynextslot = G->nextSlot ; if ((sockout = fdopen(mysock, "w")) == (FILE )NULL) { perror("fdopen") ; pthread_exit((void )NULL) ; while (stillconnected) { int i ; while (mynextslot == G->nextSlot) { sleep(1) ; #ifdef DEBUG printf("nextslot = %d, G->nextSlot = %d\n", mynextslot, G->nextSlot) ; / spinning / bcopy((void )&G->buff[myNextSlot], (void )&mylinebuff, sizeof(struct linebuff)); for (i=0; i<mylinebuff.size && stillconnected; ++i) if (fputc((int) mylinebuff.buff[i], sockout) == EOF) stillconnected = 0 ; if (stillconnected && (fflush(sockout) == EOF)) stillconnected = 0 ; INCRSLOT(&myNextSlot) ; return ((void )NULL) ;
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 informationCS321: Computer Networks Socket Programming
CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs
More informationCS307 Operating Systems Processes
CS307 Processes Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Process Concept Process a program in execution An operating system executes a variety of
More informationProcesses. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State
CS307 Process Concept Process a program in execution Processes An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks All these activities are
More informationIntroduction to Client-Server Model
Preview Introduction to Client-Server Model Motivation of Client-Server Model Terminologies and Concepts in Client-Server Model Connectionless vs. Connection-Oriented Stateless vs. Stateful Server Identify
More informationNETWORK AND SYSTEM PROGRAMMING. I/O Multiplexing: select and poll function
NETWORK AND SYSTEM PROGRAMMING LAB 15 I/O Multiplexing: select and poll function 15.1 objectives What is a Concurrent server Use of Select System call Use of Poll System call 15.2 What is concurrent server?
More information// Embedded Systems // BeagleBoard-XM. // Author : Jose Goncalves //
// Embedded Systems // BeagleBoard-XM // Author : Jose Goncalves // jose.braga.pt@gmail.com // Teacher : Nuno Peixoto // University : IPCA // 17.03.2014 #include #include #include
More informationPiotr Mielecki Ph. D.
Piotr Mielecki Ph. D. http://mielecki.ristel.pl/ piotr.mielecki@pwr.edu.pl pmielecki@gmail.com Building blocks of client-server applications: Client, Server, Middleware. Simple client-server application:
More informationNetwork Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.
Simple TCP Clients and Servers on *nix with C. Aims. This worksheet introduces a simple client and a simple server to experiment with a daytime service. It shows how telnet can be used to test the server.
More informationEmbedded System Design
Embedded System Design Lecture 9 Jaeyong Chung Robust Systems Laboratory Incheon National University Inter-process Commnucation (IPC) Chung EPC6071 2 Inter-process Commnucation (IPC) A set of methods for
More informationCS 3305 Intro to Threads. Lecture 6
CS 3305 Intro to Threads Lecture 6 Introduction Multiple applications run concurrently! This means that there are multiple processes running on a computer Introduction Applications often need to perform
More informationUNIX Network Programming. Overview of Socket API Network Programming Basics
UNIX Network Programming Overview of Socket API Network Programming Basics 1 Client-Server Model Client Machine A Network Server Machine B Web browser and server FTP client and server Telnet client and
More informationCS321: Computer Networks Introduction to Application Layer
CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the
More informationSystem Programming. Sockets: examples
Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Socket based client/server
More informationThe BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)
The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1 Work Individually (no groups) Due Date: in class, Monday, September 19 Robert T Olsen olsen@cswiscedu 7390CS Office Hours: 3-5T, 11-12F - exception
More informationMessage passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server.
Client-Server Model Message passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server. servers provide services requested
More information518 Lecture Notes Week 12
518 Lecture Notes Week 12 (November 16, 2014) 1/13 518 Lecture Notes Week 12 1 Topics TCP/IP C programing for sockets 2 TCP/IP The socket call (socket_create.c) int main(int argc, char *argv[]) int socket_desc;
More informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over
More informationInter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1
Inter-Process Communication Disclaimer: some slides are adopted from the book authors slides with permission 1 Today Inter-Process Communication (IPC) What is it? What IPC mechanisms are available? 2 Inter-Process
More informationECE322 Systems Programming Project 2: Networking with Matrix Multiplication in C Grant Kimes 12/16/15
ECE322 Systems Programming Project 2: Networking with Matrix Multiplication in C Grant Kimes 12/16/15 This project take two inputted matrices of a given size to multiply. The client sends the data to a
More informationHyo-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 informationPOSIX threads CS 241. February 17, Copyright University of Illinois CS 241 Staff
POSIX threads CS 241 February 17, 2012 Copyright University of Illinois CS 241 Staff 1 Recall: Why threads over processes? Creating a new process can be expensive Time A call into the operating system
More informationCS 3516: Computer Networks
Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top
More information1 /* client.c - adapted from code for example client program that uses TCP */ 2 /*Modified by Vincent Chu, Winter
1 /* client.c - adapted from code for example client program that uses TCP */ 2 /*Modified by Vincent Chu, Winter 2004. 3 http://www.sfu.ca/~vwchu 4 chuvincent (at) gmail (dot) com 5 */ 6 7 #define closesocket
More informationCS 471 Operating Systems. Spring 2016 Midterm Exam Time 2 & 1/2 hours. Open Book & Notes
CS 471 Operating Systems Spring 2016 Midterm Exam Time 2 & 1/2 hours Open Book & Notes Name: Unix Login: Question 1 (20 points) A. What is the output of the following program if executed as: % Q1A Q1A.c
More informationHow to write a Measurement Telnet Server
How to write a Measurement Telnet Server A measurement Telnet server allows you to access remote I/Os with a standard Telnet client program. The following samples shows a way to set the LEDs of a DNP/EVA1
More informationSockets. 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 informationECE 435 Network Engineering Lecture 2
ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 August 2017 Announcements Homework 1 will be posted. Will be on website, will announce
More informationLecture 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 informationUnix 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 informationSocket 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 informationHow do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs
Introduction to Unix Network Programming Reference: Stevens Unix Network Programming How do we Communicate? Send a mail from Alice to Bob Bob Alice in Champaign, Bob in Hollywood Example: US Postal Service
More informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Echo Client (1) 2 #include #include #include #include
More informationNetwork Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions
Network Programming in C: The Berkeley Sockets API Networked Systems 3 Laboratory Sessions The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available
More informationsocketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware
socketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware Presented at the 24th annual Tcl/Tk conference, Houston Texas, October 2017 Abstract: Horizontal scaling is used to distribute
More informationCS 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 informationReview. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection
Review Preview Algorithms and Issues in Client Software Design Client Architecture Identifying the Location of a Parsing an Address Argument Looking Up a Domain Name Looking Up a Well-Known Port by Name
More informationCSE 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 informationIntroduction to Socket Programming
Introduction to Socket Programming (Advanced Computer Networks) By Priyank Shah NET ID : pss160530 A Simple Question What are Sockets? Sockets are communication points on the same or different computers
More informationECE 435 Network Engineering Lecture 2
ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 6 September 2018 Announcements Homework 1 will be posted. Will be on website, will announce
More informationLab 0. Yvan Petillot. Networks - Lab 0 1
Lab 0 Yvan Petillot Networks - Lab 0 1 What You Will Do In This Lab. The purpose of this lab is to help you become familiar with the UNIX/LINUX on the lab network. This means being able to do editing,
More informationCSE 333 Lecture 16 - network programming intro
CSE 333 Lecture 16 - network programming intro Hal Perkins Department of Computer Science & Engineering University of Washington Today Network programming - dive into the Berkeley / POSIX sockets API -
More informationUnix Network Programming
Introduction to Computer Networks Polly Huang EE NTU Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide to Network Programming 1 The Unix Socket A file descriptor
More informationA. Basic Function Calls for Network Communications
IV. Network Programming A. Basic Function Calls for Network Communications 1 B. Settings for Windows Platform (1) Visual C++ 2008 Express Edition (free version) 2 (2) Winsock Header and Libraries Include
More informationl27 handout.txt buggy server.c Printed by Michael Walfish Apr 29, 10 13:41 Page 1/1 Apr 29, 10 11:51 Page 1/1
Apr 29, 10 13:41 Page 1/1 1 Handout for CS 372H 2 Class 27 3 29 April 2010 4 5 1. Introduction to buffer overflow attacks 6 7 There are many ways to attack computers. Today we study the 8 "classic" method.
More informationStoneGate Firewall/VPN 2.5 TECHNICAL NOTE. Server Pool Monitoring Agent Protocol
StoneGate Firewall/VPN 2.5 TECHNICAL NOTE Server Pool Monitoring Agent Protocol Protocol Description This document describes the Server Pool Monitoring Agent Protocol that is used for communications between
More informationPA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~
Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will
More informationHow to write a Measurement Telnet Server
How to write a Measurement Telnet Server A measurement Telnet server allows you to access remote I/Os with a standard Telnet client program. The following samples shows a way to set the LEDs of a DNP/EVA2
More informationA GENERALIZED FRAMEWORK FOR CATV TRANSMISSION ON FUTURE BISDN
A GENERALIZED FRAMEWORK FOR CATV TRANSMISSION ON FUTURE BISDN Geng-Sheng (G.S.) Kuo Department of Information Management, National Central University Chung-Li, Taiwan 32054, R.O.C. TEL: +886 3 4263086
More informationCSE 333 SECTION 8. Sockets, Network Programming
CSE 333 SECTION 8 Sockets, Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls Server side network programming steps and calls dig and ncat tools Network
More informationTCP/IP Sockets in C: Practical Guide for Programmers. Computer Chat. Internet Protocol (IP) IP Address. Transport Protocols. Ports
TCP/IP Sockets in C: Practical Guide for Programmers Computer Chat! How do we make computers talk? Michael J. Donahoo Kenneth L. Calvert Morgan Kaufmann Publisher $14.95 Paperback! How are they interconnected?
More informationNetwork programming(i) Lenuta Alboaie
Network programming(i) Lenuta Alboaie adria@info.uaic.ro 2017 2018 Computer Network http://www.info.uaic.ro/~computernetworks 1 Content Client/server paradigm API for network programming BSD Socket Characteristics
More informationConcurrent Programming. Concurrent Programming with Processes and Threads
Concurrent Programming Concurrent Programming with Processes and Threads Review The fork system call creates a process Memory and resources are allocated The exec system call allow a program to execute
More informationTCP Echo Application: Client & Server. TA: Awad A Younis Class: CS457 Fall 2014
TCP Echo Application: Client & Server TA: Awad A Younis Class: CS457 Fall 2014 Outline Echo Server TCP-Client TCP-Server 2 Echo Server The server simply echo whatever it receives back to the client Echo:
More informationCSC209H Lecture 10. Dan Zingaro. March 18, 2015
CSC209H Lecture 10 Dan Zingaro March 18, 2015 Creating a Client To create a client that can connect to a server, call the following, in order: socket: create a communication endpoint This is the same as
More informationpthreads Announcement Reminder: SMP1 due today Reminder: Please keep up with the reading assignments (see class webpage)
pthreads 1 Announcement Reminder: SMP1 due today Reminder: Please keep up with the reading assignments (see class webpage) 2 1 Thread Packages Kernel thread packages Implemented and supported at kernel
More informationInter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1
Inter-Process Communication Disclaimer: some slides are adopted from the book authors slides with permission 1 Today Inter-Process Communication (IPC) What is it? What IPC mechanisms are available? 2 Inter-Process
More informationJava Basics 5 - Sockets. Manuel Oriol - May 4th, 2006
Java Basics 5 - Sockets Manuel Oriol - May 4th, 2006 Connected / Disconnected Modes Connected mode: path chosen and packets arrive all, in correct order (e.g. Phone) Disconnected mode: path not chosen
More informationOperating systems fundamentals - B06
Operating systems fundamentals - B06 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B06 1 / 12 Introduction Introduction to threads Reminder
More informationThe Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4
The Berkeley Sockets API Networked Systems Architecture 3 Lecture 4 The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available on most platforms: Linux,
More informationCSE 421/521 - Operating Systems Fall 2011 Recitations. Recitation - III Networking & Concurrent Programming Prof. Tevfik Kosar. Presented by...
CSE 421/521 - Operating Systems Fall 2011 Recitations Recitation - III Networking & Concurrent Programming Prof. Tevfik Kosar Presented by... University at Buffalo September..., 2011 1 Network Programming
More informationCSE 333 Lecture 8 - file and network I/O
CSE 333 Lecture 8 - file and network I/O Steve Gribble Department of Computer Science & Engineering University of Washington CSE333 lec 8 net // 04-13-12 // gribble Administrivia HW1 was due yesterday
More informationNetwork Programming in C. Networked Systems 3 Laboratory Sessions and Problem Sets
Network Programming in C Networked Systems 3 Laboratory Sessions and Problem Sets Lab Timetable, Aims, and Objectives Teaching Week Activity 14 Introduction 15 Warm-up exercise 16 17 Web client 18 19 20
More informationThreads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits
CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process
More informationChapter 6. The Transport Layer. Transport Layer 3-1
Chapter 6 The Transport Layer Transport Layer 3-1 Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems
More informationLecture 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 informationCSE 333 SECTION 9. Threads
CSE 333 SECTION 9 Threads HW4 How s HW4 going? Any Questions? Threads Sequential execution of a program. Contained within a process. Multiple threads can exist within the same process. Every process starts
More informationConcurrent Programming
Concurrent Programming Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Jinhong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int
More informationMore Network Programming
More Network Programming More Network Programming HTTP push server Request framing and server push concepts Demo Useful API s select/poll and advanced sockets tidbits threads HTTP push server code Components
More informationProgramming in C. Session 8. Seema Sirpal Delhi University Computer Centre
Programming in C Session 8 Seema Sirpal Delhi University Computer Centre File I/O & Command Line Arguments An important part of any program is the ability to communicate with the world external to it.
More informationClient software design
Client software design Stefan D. Bruda Winter 2018 A TCP CLIENT 1 Get the IP address and port number of the peer 2 Allocate a socket 3 Choose a local IP address 4 Allow TCP to choose an arbitrary, unused
More informationLinux Network Programming, Part 1
Linux Network Programming, Part 1 http://www.linuxjournal.com/article/2333?page=0,0 Feb 01, 1998 By Ivan Griffin and John Nelson This is the first of a series of articles about how to develop networked
More informationPOSIX Semaphores. Operations on semaphores (taken from the Linux man page)
POSIX Semaphores A variable of type sem_t Example Declaration of a semaphore sem_t sem; Operations on semaphores (taken from the Linux man page) int sem_init(sem_t *sem, int pshared, unsigned int value);
More informationCPSC 341 OS & Networks. Threads. Dr. Yingwu Zhu
CPSC 341 OS & Networks Threads Dr. Yingwu Zhu Processes Recall that a process includes many things An address space (defining all the code and data pages) OS resources (e.g., open files) and accounting
More informationFile IO and command line input CSE 2451
File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to
More informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0)
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0) Overview Exam 2 will be in class on Thursday, April 13, 2017 from 10:00-11:45AM (please arrive
More informationConcurrency. Johan Montelius KTH
Concurrency Johan Montelius KTH 2017 1 / 32 What is concurrency? 2 / 32 What is concurrency? Concurrency: (the illusion of) happening at the same time. 2 / 32 What is concurrency? Concurrency: (the illusion
More informationpthreads CS449 Fall 2017
pthreads CS449 Fall 2017 POSIX Portable Operating System Interface Standard interface between OS and program UNIX-derived OSes mostly follow POSIX Linux, macos, Android, etc. Windows requires separate
More informationNote: The following (with modifications) is adapted from Silberschatz (our course textbook), Project: Producer-Consumer Problem.
CSCI-375 Operating Systems Lab #5 Semaphores, Producer/Consumer Problem October 19, 2016 Note: The following (with modifications) is adapted from Silberschatz (our course textbook), Project: Producer-Consumer
More informationWhat is concurrency? Concurrency. What is parallelism? concurrency vs parallelism. Concurrency: (the illusion of) happening at the same time.
What is concurrency? Concurrency Johan Montelius KTH 2017 Concurrency: (the illusion of) happening at the same time. A property of the programing model. Why would we want to do things concurrently? What
More informationSockets 15H2. Inshik Song
Sockets 15H2 Inshik Song Internet CAU www server (www.cau.ac.kr) Your web browser (Internet Explorer/Safari) Sockets 2 How do we find the server? Every computer on the Internet has an Internet address.
More informationCSE 333 SECTION 7. Client-Side Network Programming
CSE 333 SECTION 7 Client-Side Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls dig and ncat tools Network programming for the client side Recall the
More informationCSE 333 SECTION 7. C++ Virtual Functions and Client-Side Network Programming
CSE 333 SECTION 7 C++ Virtual Functions and Client-Side Network Programming Overview Virtual functions summary and worksheet Domain Name Service (DNS) Client side network programming steps and calls dig
More informationCSC209H 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 informationCS333 Intro to Operating Systems. Jonathan Walpole
CS333 Intro to Operating Systems Jonathan Walpole Threads & Concurrency 2 Threads Processes have the following components: - an address space - a collection of operating system state - a CPU context or
More informationAzblink API for Sending XMPP Messages via HTTP POST
Azblink API for Sending XMPP Messages via HTTP POST Abstract: This document is to describe the API of Azblink SBC for sending XMPP messages via HTTP POST. This is intended for the systems or the devices
More informationComputer Systems Laboratory Sungkyunkwan University
Concurrent Programming Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet, SOCK_STREAM, 0); bzero((char
More informationΕργαστήριο 9 I/O Multiplexing
Εργαστήριο 9 I/O Multiplexing Στοεργαστήριοθαμελετηθούν: Server High Level View I/O Multiplexing Solutions for Concurrency nonblocking I/O Use alarm and signal handler to interrupt slow system calls. Use
More informationl27 handout.txt buggy server.c Printed by Michael Walfish Apr 28, 11 15:24 Page 1/1 Apr 27, 11 1:53 Page 1/2
Apr 28, 11 15:24 Page 1/1 1 Handout for CS 372H 2 Class 27 3 28 April 2011 4 5 1. Introduction to buffer overflow attacks 6 7 There are many ways to attack computers. Today we study the 8 "classic" method.
More informationProgramming 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 informationCSE 333 SECTION 6. Networking and sockets
CSE 333 SECTION 6 Networking and sockets Overview Network Sockets IP addresses and IP address structures in C/C++ DNS Resolving DNS names Demos Section exercise Sockets Network sockets are network interfaces
More informationQ1: /8 Q2: /30 Q3: /30 Q4: /32. Total: /100
ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam Three November 20 th 2013 Name: Q1: /8 Q2: /30 Q3: /30 Q4: /32 Total: /100 1/10 For functional call related questions, let s assume
More informationCS510 Operating System Foundations. Jonathan Walpole
CS510 Operating System Foundations Jonathan Walpole Threads & Concurrency 2 Why Use Threads? Utilize multiple CPU s concurrently Low cost communication via shared memory Overlap computation and blocking
More informationICT 6544 Distributed Systems Lecture 5
ICT 6544 Distributed Systems Lecture 5 Hossen Asiful Mustafa Message Brokers Figure 4-21. The general organization of a message broker in a message-queuing system. IBM s WebSphere Message-Queuing System
More informationOutline. 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 informationNetwork Programming November 3, 2008
15-213 Network Programming November 3, 2008 Topics Programmer s view of the Internet (review) Sockets interface Writing clients and servers class20.ppt A Client-Server Transaction Most network applications
More informationThread Fundamentals. CSCI 315 Operating Systems Design 1
Thread Fundamentals Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne, as well as the tutorial by Blaise Barney
More informationCSci 4061 Introduction to Operating Systems. (Threads-POSIX)
CSci 4061 Introduction to Operating Systems (Threads-POSIX) How do I program them? General Thread Operations Create/Fork Allocate memory for stack, perform bookkeeping Parent thread creates child threads
More informationCS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco
CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level
More informationWhy a Computer Network??? Stand alone Computer. For What?
Computer Network Josua M Sinambela, CCNP, CCNA, CEH, CompTIA Security+ Computer Network & Security Consultant RootBrain IT Training & Consulting Email : josh@rootbrain.com Website: www.rootbrain.com 1
More information