Computer Networks Sockets. Sockets and the OS F An end-point for Internet connection –What the application “plugs into” –OS provides Application Programming.

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

Socket Programming. Basics Socket is an interface between application and network – Application creates a socket – Socket type dictates the style of communication.
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Sop, Fan Reference: Daniel Spangenberger Computer Networks PPT-4 Socket Programming.
CS3505 The Internet and Info Hiway transport layer protocols : TCP/UDP.
I/O Multiplexing Road Map: 1. Motivation 2. Description of I/O multiplexing 3. Scenarios to use I/O multiplexing 4. I/O Models  Blocking I/O  Non-blocking.
Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
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.
Socket Programming.
Multimedia Networking Sockets. Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
1 Java Networking – Part I CS , Spring 2008/9.
Sockets IMGD Outline Socket basics Socket details (TCP and UDP) Socket options Final notes.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
1 Socket Interfaces Professor Jinhua Guo CIS527 Fall 2003.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
Introduction to Project 1 Web Client and Server Jan 2006.
Computer Networks Sockets. Outline F Socket basics F Socket details.
Advanced UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
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
IP Multiplexing Ying Zhang EECS 489 W07.
UNIX Sockets COS 461 Precept 1.
Process-to-Process Delivery:
IP and Errors IP Best Effort Datagrams can be: –Lost –Delayed –Duplicated –Delivered out of order –Corrupted.
Signal-Driven I/O Concepts and steps for using signal-driven I/O
IT COOKBOOK Windows Network Programming. Chapter 01. Intro. to Network and Socket Programming.
Internet Applications and Network Programming Dr. Abraham Professor UTPA.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
11 TRANSPORT LAYER PROTOCOLS Chapter 6 TCP and UDP SPX and NCP.
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.
Chapter 2 Applications and Layered Architectures Sockets.
Remote Shell CS230 Project #4 Assigned : Due date :
TELE 402 Lecture 4: I/O multi … 1 Overview Last Lecture –TCP socket and Client-Server example –Source: Chapters 4&5 of Stevens’ book This Lecture –I/O.
1 I/O Multiplexing We often need to be able to monitor multiple descriptors:We often need to be able to monitor multiple descriptors: –a generic TCP client.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
Overview of TCP/IP protocols –Application layer (telnet, ssh, http, ftp, etc) The things that we use daily. –Transport layer (TCP, UDP) Allows processes.
I/O Multiplexing. TCP Echo Client: I/O operation is sequential !! tcpcliserv/tcpcli01.c: lib/str_cli.c: TCP Client TCP Server stdin stdout fgets fputs.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Socket Programming.
Advanced UNIX programming Fall 2002, lecture 16 Instructor: Ashok Srinivasan Acknowledgements: The syllabus and power point presentations are modified.
Today’s topic: UDP Reliable communication over UDP.
CMPT 471 Networking II Network Programming © Janice Regan,
2: Application Layer 1 Socket Programming UNIX Network Programming, Socket Programming Tutorial:
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
EECS340 Recitation 1: Very helpful to your project Hongyu Gao 1.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Network Communications A Brief Introduction. 2 Network Communications.
@Yuan Xue CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Process-to-Process Delivery:
Chapter 9 The Transport Layer The Internet Protocol has three main protocols that run on top of IP: two are for data, one for control.
SOCKET PROGRAMMING Presented By : Divya Sharma.
I/O Multiplexing.
Operating Systems Sockets ENCE 360.
UNIX Sockets COS 461 Precept 1.
Review: TCP Client-Server Interaction
Lecture 4 Socket Programming Issues
Process-to-Process Delivery:
Lecture 11 Overview.
Socket Programming.
TCP/IP Socket Programming in C
CSC Advanced Unix Programming, Fall 2015
I/O Multiplexing We often need to be able to monitor multiple descriptors: a generic TCP client (like telnet) need to be able to handle unexpected situations,
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

Computer Networks Sockets

Sockets and the OS F An end-point for Internet connection –What the application “plugs into” –OS provides Application Programming Interface (API) User Socket Operating System Network

Socket Basics F User sees “descriptor”, integer index –like: FILE *, or file index F End point determined by two things: –Host addr: Internet address of machine (street) –Port num: Where application receives (number) F Two end-points determine a connection: socket pair –ex: reno.wpi.edu,p21 + bert.wpi.edu,p1500 –ex: bill.microsoft.com,p21 + linus.linux.org,p1499

Ports F Numbers: – “reserved”, must be root – “ephemeral” –however, many systems allow > 3977 ports u (50,000 is correct number) F /etc/services: ftp 21 telnet 23 finger 79 httpd 80

Internet Protocols F TCP: Transmission Control Protocol –reliable (in order, all arrive, no duplicates) –flow control –connection –duplex F UDP: User Datagram Protocol –no acknowledgements –no retransmissions –out of order, duplicate possible –connectionless

Client-Server sockcreate() sockaccept() recv() Server sockconnect() send() recv() Client (Block until receive data) send() Data (request) Data (reply) close() “ well-known” port fork() (Block until connection ) “Handshake” recv() close() End-of-File

Samples

fcntl() F ‘File control’ but used for sockets, too F Set socket non-blocking flags = fcntl(sockfd, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(sockfd, F_SETFL, flags);  Beware not getting flags before setting!

select() F Wait for any in set of descriptors to be ready –data, error, closed int select(int max, fd_set *readset, fd_set *writeset, fd_set *excepset, timeval *timeout); F check for reading,writing, exceptions  fd_set contains set of descriptors (bits in array) –FD_ZERO () - clear all bits –FD_SET () - turn on specific fd –FD_CLR () - turn off specific fd –FD_ISSET() - check if fd bit is set  Ex: fd_set rset: –FD_ZERO (&rset); /* clear bits */ –FD_SET (1, &rset); /* turn on bit for fd 1 */

Select between stdin and socket FD_ZERO(&rset); while (1) { FD_SET(fileno(stdin), &rset); FD_SET(sockfd, &rset); max = max(fileno(stdin), sockfd) + 1; select(max, &rset, NULL, NULL, NULL); if (FD_ISSET(sockfd, &rset)) /* do socket stuff */; if (FD_ISSET(fileno(stdin), &rset)) /* do stdin stuff */; }