Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
|
|
- Esther Harvey
- 6 years ago
- Views:
Transcription
1 Internettechnologien (CS262) Socket Programming in C 4. März 2015 Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel Introduction What is a socket? A socket is a bi-directional communication abstraction (called association) between two processes. A socket is the endpoint of a communication. Sockets is an Application Programming Interface (API) for InterProcess Communication (IPC) process 1 process 2 socket socket e.g. web browser (Mozilla, Internet Explorer) e.g. web 2
2 Introduction There are may types of sockets SOCK_STREAM: TCP (connection oriented, guaranteed delivery) SOCK_DGRAM: UDP (datagram-based communication) SOCK_RAW: allows access to the network layer. This can be used to build ICMP messages or custom IP packets. SOCK_PACKET: allows access to the link-layer (e.g. Ethernet). This can be used to build entire frames (e.g. to build a user-space router). 3 Introduction There are many domains and (P)rotocol (F)amilies to deal with PF_INET: IP version 4 (32-bit addresses) PF_INET6: IP version 6 (128-bit addresses) PF_UNIX: interprocess communication on the local machine PF_APPLETALK: Appletalk networks PF_IPX: Novell Netware networks... PF_ROUTE: access to routing tables (*BSD systems) 4
3 Introduction Web browser Port HTTP Port 80 PF_INET, SOCK_STREAM (IPv4) (TCP) Want to check active sockets on your machine? # netstat -ap -A inet (or inet6, or unix) Active Internet connections (s and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 *:ipp *:* LISTEN 1437/cupsd tcp : ESTABLISHED1621/mozilla-thunde tcp : ESTABLISHED1621/mozilla-thunde tcp :32769 clarinet.u-strasb:imaps ESTABLISHED1621/mozilla-thunde tcp 0 *:bootpc *:* 1271/dh udp 0 *:ipp *:* 1437/cupsd udp 0 *:icmp *:* 1720/vmnet-natd 5 Socket creation int socket (int domain, int type, int protocol); domain: PF_INET, PF_INET6, PF_UNIX,... type: SOCK_DGRAM, SOCK_STREAM,... protocol: 0=default, or IPPROTO_UDP, IPPROTO_TCP, The returned value is a descriptor (i.e., an integer value that uniquely identifies the socket among other descriptors such as sockets, files, pipes, etc.) Example: int my_socket; my_socket = socket(af_inet, SOCK_STREAM, 0); 6
4 Socket address configuration struct sockaddr_in { short int sin_family; /* domain*/ unsigned short int sin_port; /* port number */ struct in_addr sin_addr; /* IP address */ unsigned char sin_zero[8]; /* padding with zeros */}; struct in_dadr { unsigned long s_addr; }; Purpose of structure: easy access to socket parameters Basic structure: sockaddr But one should always use the appropriate sockaddr_xxx when accessing a specific structure type (e.g. sockaddr_in) sockaddr sockaddr_in family blob family port addr zero 7 Watch the conversions!!! Convert multibyte integers in decimal = c734 in hexadecimal there are two ways to encode this number in 32 bits: 34-c = host byte order (little-endian, Intel) c7-34 = host byte order (big-endian, Motorola, IBM) memory n...n c7-34 = network byte order (big-endian, for all machines!) sin_port and sin_addr MUST be in network byte order When building a packet (SOCK_RAW or SOCK_PACKET), all data fields must be in network byte order! 8
5 Integer conversion functions htonl host to network long (to convert a long integer (32 bit) from host to network byte order, before tx) htons host to network short (to convert a short integer (16 bit) from host to network byte order, before tx) ntohl network to host long (after rx) ntohs network to host short (after rx) Caution: Don t convert chars! Example: struct sockaddr_in webyahooaddr; webyahooaddr.sin_family = AF_INET; webyahooaddr.sin_port = htons(80); webyahooaddr.sin_addr.s_addr = inet_addr( ); memset(&webyahooaddr.sin_zero, \0, 8); 9 Datagram-based communication Function calls with UDP (SOCK_DGRAM) station 1 station 2 sendto()/recvfrom() data sendto()/recvfrom() 10
6 Binding of the socket (to an address) Bind = Assign IP address and port number to socket Example: int mysock; struct sockaddr_in locaddr; mysock = socket(pf_inet, SOCK_STREAM, 0); /* or SOCK_DGRAM */ locaddr.sin_family = AF_INET; locaddr.sin_port = htons(0); /* let the system choose */ locaddr.sin_addr.s_addr = htonl(inaddr_any); /* any addr of machine */ memset(&locaddr, \0, 8); bind(mysock, (struct sockaddr*)&locaddr, sizeof(locaddr)); 11 Binding of the socket (to an address) Read-back auto values When calling with sin_port=0, the value chosen by the system is not saved in the structure. We must use getsockname() to update the structure. Example: int length; getsockname(mysock, (struct sockaddr*)&locaddr, &length); /* note: length is an output argument; we have to pass its address */ /* the port number is now updated and can be displayed: but remember to convert to host byte order! */ printf( Port chosen by the system is %d, ntohs(locaddr.sin_port)); 12
7 Stream-based communication Walk-through example: TCP Echo Server 13 Echo : Create socket /* create socket for incoming connections */ int = socket(pf_inet, SOCK_STREAM, 0); 14
8 Echo : Bind local address struct sockaddr_in srvaddr; srvaddr.sin_family = AF_INET; /* IPv4 address */ srvaddr.sin_port = htons(8080); /* local port */ srvaddr.sin_addr.s_addr = htonl(inaddr_any); /* any interf. */ memset(&srvaddr.sin_zero, \0, 8); /* padding */ bind(, (struct sockaddr*)&srvaddr, sizeof(srvaddr)); 15 Echo : Listen to incoming connections /* listen for incoming connections */ listen(, MAXPENDING); 16
9 Echo : Accept incoming connections for (;;) { struct sockaddr_in cliaddr; /* address */ int cliaddrlen = sizeof(cliaddr); int ; /* socket for comm. to */ = accept(, (struct sockaddr*)&cliaddr, &cliaddrlen); 17 Echo Server: Accept incoming connections Server is now blocked, waiting for an incoming connection: 18
10 Echo : Create socket /* create TCP socket for outgoing connection */ int = socket(pf_inet, SOCK_STREAM, 0); 19 Echo Client: Bind local address (optional) struct sockaddr_in cliaddr; cliaddr.sin_family = AF_INET; /* IPv4 address */ cliaddr.sin_port = 0; /* any port is fine */ cliaddr.sin_addr.s_addr = htonl(inaddr_any); /* any interf. */ memset(&srvaddr.sin_zero, \0, 8); /* padding */ bind(, (struct sockaddr*)&cliaddr, sizeof(cliaddr)); 20
11 Echo Client: Connect to struct sockaddr_in srvaddr; srvaddr.sin_family = AF_INET; /* IPv4 address */ srvaddr.sin_port = htons(8080); /* port */ srvaddr.sin_addr.s_addr = inetaddr( ); /* IP */ memset(&srvaddr.sin_zero, \0, 8); /* padding */ connect(, (struct sockaddr*)&srvaddr, sizeof(srvaddr)); 21 Echo Server: Accept incoming connections = accept(, (struct sockaddr*)&cliaddr, &cliaddrlen); Blocking call returns is the socket descriptor for communication with the 22
12 Echo Client: Send a message and wait for reply char msg[] = This is a test. ; send(, msg, strlen(msg), 0); /* wait for reply by calling recv() (not shown here) */ 23 Echo Server: Receive and send same messages #define BUFSIZE 32 char buf[bufsize]; int bytesrecv; bytesrecv = recv(, buf, BUFSIZE, 0); while (bytesrecv > 0) /* zero indicates end of transmission */ { send(, buf, bytesrecv, 0); /* echo */ bytesrecv = recv(, buf, BUFSIZE, 0); } 24
13 Echo Server: Close connection (and accept next) for (;;) {... = accept(, (struct sockaddr*)&cliaddr, &cliaddrlen);... } close(); 25 TCP Socket Features The must know the s address/port. The must only know its own port! Streaming socket: Transmission/Reception of a byte stream No correlation between bytes and segments (packets). Segmentation of the byte stream is out of the user s control (due to TCP s Flow Control) send( This is a test ); recv( Hello world ); recv() -> This i ; recv() -> s a te ; recv() -> st ; send() -> Hello send() -> world ; 26
14 TCP Socket Features is used to terminate a connection analogous to EOF (end-of-file) send(...); ; while (recv(...) > 0) { send(...) } ; Caution: Does not work with datagram socket e.g. UDP not connection-oriented = no close-notification 27 Blocking calls Be careful: calls are blocking! A call to recv(), send(), recvfrom(), and sendto() is by default a blocking call. Example: recvfrom(...); /* call blocks until a message is received */ sendto(...); The program will not be able to send if it does not receive anything! Solution 1: use the select() function Solution 2: multi-threaded applications 28
15 The select() function Used to monitor a set of descriptors (e.g. sockets, files, pipes, stdin). select() blocks until an event on the observed descriptors occurs: If we check a set in order to trigger read operations, select() returns the set that has data ready to be read. If select() is used in a loop, the initial set of descriptors must then always be initialized properly before re-calling select() The blocking behavior of select() can be changed by specifying a timeout value (last function argument). 29 Using the select() function Example: a wants to check two sockets for data to read /* the two socket descriptors are sock1 and sock2; let sockmax = (sock1 > sock2? sock1 : sock2) */ /* we first need a set of file descriptors */ fd_set readfds, backup; /* we initialize the set and add sock1 and sock2 to it */ FD_ZERO(&readfds); FD_SET(sock1, &readfds); FD_SET(sock2, &readfds); backup = readfds; /* used to save the original state */ for (;;) { select(sockmax, &readfds, NULL, NULL, NULL); if (FD_ISSET(sock1, &readfds)) recv(sock1, buf, MAX_LEN, 0); if (FD_ISSET(sock2, &readfds)) recv(sock2, buf, MAX_LEN, 0); readfds = backup; /* set readfds to initial state */ } 30
16 Multithreaded Spawn a new thread for each accepted connection for (;;) { = accept(, (struct sockaddr *)&cliaddr, &cliaddrlen); pid = fork(); if (pid == 0) /* child thread */ { close(); dostuff(); exit(0); } else /* parent thread */ { close(); /* continue in while loop: accept next connection... */ } } 31 Handle errors! Socket programming can easily lead to many errors. It is mandatory to check for errors! (for clarity, this is not done in these slides) Example: if (bind(mysock, (struct sockaddr*)&sockaddr, sizeof(sockaddr) < 0) { perror( Bind: ); /* prints out an explicit error message */ exit(-1); } Use perror() with all calls! (accept, connect,...) 32
17 Summary The socket API provides user-level abstractions for communication associations. One API for different communication types streaming, datagram-oriented, connection-oriented, connection-less and different protocols e.g. UDP, TCP, interprocess communiction, creates new socket descriptor destroys the descriptor configures/binds an address to a socket, to establish a connection-oriented session to send over pre-configured socket sendto()/recvfrom() to configure remote side on-the-fly 33
The 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 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 informationTypes (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar
Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar - Advanced Data Communications:
More informationTutorial 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 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 informationA 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 informationSocket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme
Socket Programming Dr. -Ing. Abdalkarim Awad Informatik 7 Rechnernetze und Kommunikationssysteme Before we start Can you find the ip address of an interface? Can you find the mac address of an interface?
More informationSocket 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 informationSocket Programming TCP UDP
Socket Programming TCP UDP Introduction Computer Network hosts, routers, communication channels Hosts run applications Routers forward information Packets: sequence of bytes contain control information
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 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 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 informationLecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1
Lecture 24 Log into Linux. Copy directory /home/hwang/cs375/lecture24 Final project posted. Due during finals week. Reminder: No class next Tuesday (11/24) Questions? Thursday, November 19 CS 375 UNIX
More informationContext. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement
Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications
More informationSOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles
LABORATORY SOCKET PROGRAMMING What is a socket? Using sockets Types (Protocols) Associated functions Styles 2 WHAT IS A SOCKET? An interface between application and network The application creates a socket
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 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 informationOral. 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 informationWriting Network Applications using the TCP/IP Protocol Stack: Socket Programming
Writing Network Applications using the TCP/IP Protocol Stack: Socket Programming 1 Web Browser Network - Applications Paradigm Communicating TCP UDP IP LL PL Real Player Typical network app has two pieces:
More informationTopics for this Week
Topics for this Week Layered Network Architecture ISO/OSI Reference Model Internet Protocol Suite Overview Application Programming Interface BSD Socket API Readings Sections 1.1-1.5, 6.1.3 (socket programming),
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 informationNetwork Socket Programming - 3 BUPT/QMUL
Network Socket Programming - 3 BUPT/QMUL 2017-3-27 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface
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 informationTCP Network Programming in C
CPSC 360 Network Programming TCP Network Programming in C Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu http://www.cs.clemson.edu/~mweigle/courses/cpsc360 1 Sockets
More informationWinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics
WinSock What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics What Is Sockets Standard API (Application Programming Interface) for
More informationHybrid 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 informationNetwork Socket Programming - 3 BUPT/QMUL
Network Socket Programming - 3 BUPT/QMUL 2018-04-02 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface
More informationCLIENT-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 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 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 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 informationBSD Sockets API. Mesut Ali ERGIN. Yeditepe University Information and Computer Science Department
BSD Sockets API Mesut Ali ERGIN Yeditepe University Information and Computer Science Department ergin@ics.yeditepe.edu.tr Slides prepared by Constantinos Dovrolis,, l 1o f1 4 Hosts, Ports, Interfaces,
More informationClient 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 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 informationDepartment of Computer Science
Department of Computer Science Notes on Interprocess Communication in Unix Jean Dollimore,Oct.1990, last revised Feb. 1996 These notes explain how you can write "distributed programs" in C or C++ running
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 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 informationCS 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 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 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 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 informationTCP: 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 informationSession NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software
Session NM056 Programming TCP/IP with Sockets Geoff Bryant Process software Course Roadmap Slide 57 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server
More informationUNIX 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 informationNetwork Socket Programming - 2 BUPT/QMUL
Network Socket Programming - 2 BUPT/QMUL 2017-3-20 Review Basic Concepts in NP Introduction to Network Programming Importance Classes Environments in this course Program Developing Phases Skills Useful
More informationCS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm
CS118 Discussion 1B, Week 1 Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm 1 TA Taqi, PhD student in Computer Networking Discussion (1B): Bunche 1209, Fri 12:00 1:50 p.m. Office hours: Boelter Hall
More informationSocket Programming(2/2)
Socket Programming(2/2) 1 Outline 1. Introduction to Network Programming 2. Network Architecture Client/Server Model 3. TCP Socket Programming 4. UDP Socket Programming 5. IPv4/IPv6 Programming Migration
More informationSocket Programming 2007/03/28
Socket Programming 2007/03/28 Reference W. Richard Stevens, Unix Network Programming 2/e Volume 1,1998 James F. Kurose and Keith W. Ross, "Computer Networks: A Top-Down Approach Featuring the Internet
More informationPorts 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 informationSOCKETS. COMP750 Distributed Systems
SOCKETS COMP750 Distributed Systems Sockets The Socket library is a traditional Application Program Interface (API) to the transport layer. Sockets were originally implemented in Unix systems and have
More informationTCP/IP Sockets in C: Practical Guide for Programmers. Computer Chat. Internet Protocol (IP) IP Address. Transport Protocols
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 http://www.cs.uga.edu/~maria/classes/4730-fall-2009/project3ets/!!
More informationUNIX 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 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 informationA 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 informationIntroduction to Socket Programming
UNIT II - ELEMENTARY TCP SOCKETS Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket,
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 informationsottotitolo 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 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 informationInterprocess 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 informationshared 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 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 informationSocket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles
Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Note: Java and C# sockets are conceptually quite similar 1 What is a
More informationEECS122 Communications Networks Socket Programming. Jörn Altmann
EECS122 Communications Networks Socket Programming Jörn Altmann Questions that will be Addressed During the Lecture What mechanisms are available for a programmer who writes network applications? How to
More informationSocket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory
Socket Programming Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2019 Networking Laboratory Contents Goals Client-Server mechanism Introduction to socket Programming with socket on
More informationELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition
ELEC / COMP 177 Fall 2014 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Project #1 Starts in one week Is your Linux environment all ready? Bring your laptop Work time after quick
More informationInternet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface.
15-213 Internetworking II: Network programming Berkeley sockets interface Internet protocol stack April 20, 2000 Topics client/server model Berkeley sockets TCP client and server examples UDP client and
More informationUNIX System Programming Lecture 19: IP Sockets
UNIX System Programming Lecture 19: Outline Reference BLP: Chapter 15 man pages: socket, bind, connect, listen, accept, ip(7), ipv6(7), getaddrinfo, getnameinfo 1 Review of UNIX Sockets On the server,
More informationInternetworking II: Network programming. April 20, 2000
15-213 Internetworking II: Network programming Topics April 20, 2000 client/server model Berkeley sockets TCP client and server examples UDP client and server examples I/O multiplexing with select() Internet
More informationInterprocess 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 informationIntroduction to Berkeley Sockets
INF1060: Introduction to Operating Systems and Data Communication Data Communication: Introduction to Berkeley Sockets Michael Welzl (adapted from lectures by Pål Halvorsen, Carsten Griwodz & Olav Lysne)
More informationGroup-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 informationIntroduction to Berkeley Sockets
INF1060: Introduction to Operating Systems and Data Communication Data Communication: Introduction to Berkeley Sockets Michael Welzl (revised by Hans Petter Taugbøl Kragset 2015) (adapted from lectures
More informationElementary 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 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 informationInternet applications
CSc 450/550 Computer Networks Worldwide Web Jianping Pan Summer 2006 5/18/06 CSc 450/550 1 Traditionally Internet applications remote login: e.g., telnet file transfer: e.g., FTP electronic mail: e.g.,
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 informationSocket 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 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 informationMemory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)
File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps
More informationNetwork Programming Week #1. K.C. Kim
Network Programming Week #1 K.C. Kim kckim@konkuk.ac.kr How do we communicate? Mail Example 1. Write a mail 2. Put the mail into a mailbox 3. Post office classify mails based on the address 4. Cars, airplanes
More informationNetwork Software Implementations
Network Software Implementations Number of computers on the Internet doubling yearly since 1981, nearing 200 million Estimated that more than 600 million people use the Internet Number of bits transmitted
More informationIntroduction to Berkeley Sockets
INF1060: Introduction to Operating Systems and Data Communication Data Communication: Introduction to Berkeley Sockets Michael Welzl (revised by Hans Petter Taugbøl Kragset 2015) (adapted from lectures
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 informationAnnouncements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)
Announcements CS 5565 Network Architecture and Protocols Problem Set 1 due Feb 18 Project 1A due Feb 19 Lecture 5 Godmar Back 2 Queuing Demultiplexing send queues Layer k+1 Layer k recv queues End systems
More informationCSE 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 information1.2 The first Internet (i.e., one of the first packet switched networks) was referred to as the ARPANET.
CPSC 360 Spring 2011 Exam 1 Solutions This exam is closed book, closed notes, closed laptops. You are allowed to have one 8.5x11 sheets of paper with whatever you like written on the front and back. You
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 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 informationNetworked 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 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 informationNETWORK 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 informationCSc 450/550 Computer Networks Network Architectures & Client-Server Model
CSc 450/550 Computer Networks Network Architectures & Client-Server Model Jianping Pan Summer 2007 5/17/07 CSc 450/550 1 Last lectures So far, nuts and bolts views of the Internet Internet evolution and
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 informationClient-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.
15-213 The course that gives CMU its Zip! Network programming Nov 27, 2001 Topics Client- model Sockets interface Echo and Client- model Every network application is based on the - model: Application is
More informationOutline. 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 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 informationCh 7. Network Interface
EE414 Embedded Systems Ch 7. Network Interface Part 2/2 Byung Kook Kim School of Electrical Engineering Korea Advanced Institute of Science and Technology Overview 7.1 Advanced Communication Principles
More informationCS 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 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 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 information