Socket Programming Example
|
|
- August Kelley
- 5 years ago
- Views:
Transcription
1 Socket Programming Example Amir R. Khakpour CSE422 Dept. of Computer Science and Engineering Michigan State University January 25, 2009
2 What is the problem? Message type=1, Message content= Message type=2, Message content=random_port Message type=3, Message content=client_msg Message type=4, Message content= neg_port random_port client server Two phase communication - Port number negotiation (using UDP sockets) - Message transaction (using TCP socket) Each message has three fields: - message type: integer - message content length: integer - message content: character [128]
3 Solution Command line executables - Client side:./client -s p m mymessage! - Server side:./server Source Code files - client.cc - server.cc - packet.h struct message packet { int type; int msg len; int port num; char message[128]; };
4 [client.cc] Taking care of input arguments const char* server host = " "; unsigned short neg port = 0; const char * MESSAGE=""; if (( argc!= 7 ) && ( argc!= 5 )){ cout << " Usage: " << argv[0] << " -s <hostname> -p <udp port> -m <message>" << endl; exit(0); } else for (int i=1; i<argc; ++i) if (strcmp(argv[i], "-s") == 0) server host = argv[++i]; else if (strcmp(argv[i], "-p") == 0) neg port = (short) atoi(argv[++i]); else if (strcmp(argv[i], "-m") == 0) MESSAGE=argv[++i];
5 [client.cc] Creating the UDP socket client-side Create a socket and store its descriptor int udp fd; // socket descriptor // create the socket if ( (udp fd = socket(af INET,SOCK DGRAM,0)) < 0 ) { cerr << "udp error!" << endl; exit(0); } Store the server s address in an object the network client can understand sockaddr in server; socklen t slen=sizeof(server); // length of remote address // designate the addressing family server.sin family = AF INET; server.sin port = neg port; hostent *hp = gethostbyname(server host); memcpy(&server.sin addr,hp->h addr, hp->h length); Important note: based on the operating system that you run your program on you may need to use htons() function to parse a number to server.sin port. htonl() and htons() convert long integer and short integer (respectively) from host byte order (on x86 this is Least Significant Byte First) to standard network byte order (Most Significant Byte First).
6 [server.cc] Creating the UDP socket on the server side Similar to client.cc we have: int udp fd; // udp file descriptor // create the UDP socket if ( (udp fd = socket(af INET,SOCK DGRAM,0)) < 0 ) { cerr << "udp error!" << endl; exit(0); } sockaddr in server udp; // socket address for us socklen t len = sizeof(server udp); // set up the UDP socket server udp.sin family = AF INET; // internet family server udp.sin port = 0; // system set server udp.sin addr.s addr = INADDR ANY; // wild card machine address
7 [server.cc] Creating the UDP socket on the server side (cont.) We will need to bind the socket we just created to the port // bind the name (address) to a port if ((bind(udp fd,(struct sockaddr *)&server udp, sizeof(server udp))) < 0 ) { cerr << "udp binding Error!" << endl; exit(0); } Then we need to output the port the OS selected for us to use getsockname(udp fd, (struct sockaddr *)&server udp, &len); cout << "Negotiation Port: " << server udp.sin port << endl;
8 [server.cc] Creating the TCP socket for server Similar to UDP, for TCP socketr generation we need to change SOCK DGRAM to SOCK STREAM to make the socket connection oriented. We will also have to bind the socket to the server port, like we did for the server s UDP socket. //create the TCP Socket int tcp fd; // tcp file descriptor if ( (tcp fd = socket(af INET,SOCK STREAM,0))<0) { cerr << "tcp error!" << endl; exit(0); } sockaddr in server tcp; //setupf the TCP Socket server tcp.sin family = AF INET; // internet family server tcp.sin port = 0; // get the socket port server tcp.sin addr.s addr = INADDR ANY; // wild card machine address if ((bind(tcp fd,(struct sockaddr *)&server tcp, sizeof(server tcp))) < 0) { cerr << "tcp bind error!" << endl; exit(0); } len = sizeof(server tcp); getsockname(tcp fd, (struct sockaddr *)&server tcp, &len);
9 [client.cc] Sending the first packet Create the packet using packet.h message packet rqst packet; rqst packet.type=1; rqst packet.msg len=0; bzero(rqst packet.message,128); To send the packet to the server we use command sendto(). It takes the file descriptor, the address of the packet, the size of the packet, and flag (typically always zero), the pointer to the server socket address, and the size of the address. sendto(udp fd,&rqst packet,sizeof(rqst packet),0,(struct sockaddr *)&server, slen); cout <<">> [UDP] Sent: Message Type: "<< rqst packet.type<<" Message Length: " <<rqst packet.msg len<<" Message Content: "<< rqst packet.message <<endl;
10 [server.cc] Receiving the first packet To receive from the client we use the function recvfrom(), which takes a file descriptor, the pointer to where to store the message, the max size received, a flag (typically zero), a pointer to a socket address for the sender, and the size of address as arguments. We will want to store the address for the client to respond back with the TCP port. sockaddr in client; // socket address for client socklen t clen = sizeof(client); message packet rqst packet; //receive connect request int mesglen = recvfrom(udp fd,&rqst packet,sizeof(rqst packet),0, (struct sockaddr *)&client, &clen); cout <<"<< [UDP] Received: Message Type: "<< rqst packet.type <<" Message Length: " <<rqst packet.msg len <<" Message Content: "<< rqst packet.message <<endl;
11 [server.cc] Responding to the client Once the server side receives the message it creates a message with type=2 and fill the content by TCP port number. message packet response packet; response packet.type=2; ostringstream random port; random port << server tcp.sin port; bzero(response packet.message,128); response packet.msg len=random port.str().length(); strncpy(response packet.message,random port.str().c str(), response packet.msg len); Send back the response to the client. In the same command we used for sending to the server: sendto(udp fd, &response packet, sizeof(response packet), 0,(struct sockaddr *)&client, clen); cout <<">> [UDP] Sent: Message Type: "<< response packet.type <<" Message Length: " <<response packet.msg len <<" Message Content: "<< response packet.message <<endl; We are done with the UDP file descriptor so close it. close(udp fd);
12 [client.cc] Receiving the response Like we did with the server we need to receive the packet being sent to us. message packet response packet; int mesglen = recvfrom(udp fd, &response packet,sizeof(response packet),0, (struct sockaddr *)&server, &slen); And like the server we are done with the file descriptor. close(udp fd); And we print out the received packet. char out1[128]=""; strncpy(out1,response packet.message,response packet.msg len); cout <<"<< [UDP] Received: Message Type: "<< response packet.type <<" Message Length: "<<response packet.msg len <<" Message Content: "<< out1 <<endl; cout << "So the Random port (random port) is: "<< out1 << endl;
13 [client.cc] Creating the TCP socket for client Just like the server we will need to create a socket for the TCP connection. int tcp fd; if ( (tcp fd = socket(af INET, SOCK STREAM, 0)) < 0) { cerr << "tcp error!" << endl; exit(0); }
14 [server.cc] Wait for a connection request and accept Now that we have a socket and the client matches the username, we need to listen for their connection and accept the connection. Also we should close the first TCP file descriptor because we no longer are listening for connections. listen(tcp fd, 1); int acc tcp fd = accept(tcp fd, (struct sockaddr *)0, (socklen t *)0); close(tcp fd); Make sure the file descriptor exists, otherwise quit. if(acc tcp fd == -1) { cout << "accept failure" << endl; exit(0); }
15 [client.cc] Connecting to the server We update the port number by the random port and then connect to the server with the address and port we received the response packet from. // update the server socket port number server.sin port = atoi(out1); if(connect(tcp fd, (struct sockaddr*)&server, slen) < 0) { cout << "connection error" << endl; close(tcp fd); exit(0); }
16 [client.cc] Sending a message to the server Now that we are connected, let s send messages to the server. char out2[128]=""; message packet client msg; client msg.type=3; client msg.msg len=strlen(message); bzero(client msg.message,128); strncpy(client msg.message,message,client msg.msg write(tcp fd, &client msg, sizeof(client msg)); cout <<">> [TCP] Sent: Message Type: "<< client msg.type <<" Message Length: " <<client msg.msg len <<" Message Content: "<< MESSAGE <<endl;
17 [server.cc] Receiving a message from client message packet client msg; // receive the message mesglen = read(acc tcp fd, &client msg, sizeof(client msg)); cout <<"<< [TCP] Received: Message Type: "<< client msg.type <<" Message Length: " <<client msg.msg len <<" Message Content: "<< client msg.message <<endl;
18 [server.cc] Sending a message to the client The server writes on the socket and the client will read that message packet rcv msg; rcv msg.type=4; rcv msg.msg len=0; write(acc tcp fd, &rcv msg, sizeof(rcv msg)); char out3[128]=""; strncpy(out3,rcv msg.message,rcv msg.msg len); cout <<">> [TCP] Sent: Message Type: "<< rcv msg.type <<" Message Length: " <<rcv msg.msg len <<" Message Content: "<< out3 <<endl;
19 [client.cc] Receiving a message from server char out3[128]=""; message packet rcv msg; read(tcp fd, &rcv msg, sizeof(rcv msg)); strncpy(out3,rcv msg.message,rcv msg.msg len); cout <<"<< [TCP] Received: Message Type: "<< rcv msg.type <<" Message Length: " <<rcv msg.msg len <<" Message Content: "<< out3 <<endl;
20 Cleaning up We need to close all the open file descriptors before we exit. server.cc: // close the socket close(acc tcp fd); client.cc: close(tcp fd);
Ken French HELP Session 1 CS4514
Ken French HELP Session 1 CS4514 CS4514 We expect that you have had a programming course similar to 2005 before coming into this class. Programs will be done in C or C++ We also expect that you will have
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 informationSockets Sockets Communication domains
Sockets Sockets The original method for process communication in UNIX is pipes. A disadvantage with pipes is that they can only be used by processes that have the same parent process. When communicating
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 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
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 Introducing 2 3 Internet
More information// socket for establishing connections
#include #include #include #include #include #include #include #define FILELENGTH 511 // This is not right #define
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 informationIntroduction to Socket Programming
Introduction to Socket Programming Sandip Chakraborty Department of Computer Science and Engineering, INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR March 21, 2017 Sandip Chakraborty (IIT Kharagpur) CS 39006
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 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 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 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 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 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 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 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 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 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 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 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 informationProject 3. Reliable Data Transfer over UDP. NTU CSIE Computer Networks 2011 Spring
Project 3 Reliable Data Transfer over UDP NTU CSIE Computer Networks 2011 Spring Project Goal In Project 3, students are asked to understand and implement reliable data transfer mechanism over UDP. UDP
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 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 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 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 informationCS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3)
CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3) Speaker: Frank Posluszny Outline! Project 1 Overview! Unix Network Programming Client Server Communication with netoracle! Project
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 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 informationSTUDY OF SOCKET PROGRAMMING
STUDY OF SOCKET PROGRAMMING Sockets : An application programming interface(api) used for inter process communication. Sockets allow communication between two different processes on the same or different
More informationCSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1
CSMC 412 Computer Networks Prof. Ashok K Agrawala 2015 Ashok Agrawala Set 2 September 15 CMSC417 Set 2 1 Contents Client-server paradigm End systems Clients and servers Sockets Socket abstraction Socket
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 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 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 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 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 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 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 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 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 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 informationUDP CONNECT TO A SERVER
UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
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 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 informationCS4514 B08 HELP Session 1
CS4514 B08 HELP Session 1 Presented by Choong-Soo Lee clee01@cs.wpi.edu CS4514 TCP/IP Socket Programming Outline Project 1 Overview Unix Network Programming TCP Client TCP Server Processing commands How
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 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 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 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 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 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 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 informationIntroduction to Computer Systems. Networks 2. c Theodore Norvell. The Sockets API
The Sockets API [Wait! If you are not familiar with file descriptors and the UNIX read and write system calls, read chapter 10 of Bryant and O Hallaron and/or my summary before going on.] In this section
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 informationThe User Datagram Protocol
The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms ffl shared storage These mechanisms have already been covered. examples: Λ shared virtual memory Λ shared files processes must agree on
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 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 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 informationC Structures in Practice
CS 2060 Use of C Structures in Unix/Linux To further illustrate C structures, we will review some uses of struct in system calls. Here is a function from BSD to get the current time (found in sys/time.h):
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 informationNetworked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers
Networked Applications: Sockets CS 375: Computer Networks Spring 2009 Thomas Bressoud 1 Goals of Todayʼs Lecture Client-server paradigm End systems Clients and servers Sockets and Network Programming Socket
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 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 informationChristian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
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
More informationComputer Network Lab, SS Fachgebiet Technische Informatik, Joachim Zumbrägel. Overview. Sockets. Sockets in C.
Computer Network Lab 2016 Fachgebiet Technische Informatik, Joachim Zumbrägel Overview Sockets Sockets in C Sockets in Delphi 1 Inter process communication There are two possibilities when two processes
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 informationComputer Networks Prof. Ashok K. Agrawala
CMSC417 Computer Networks Prof. Ashok K. Agrawala 2018Ashok Agrawala September 6, 2018 Fall 2018 Sept 6, 2018 1 Overview Client-server paradigm End systems Clients and servers Sockets Socket abstraction
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 informationMPAC BENCHMARKING LIBRARY
MPAC BENCHMARKING LIBRARY Table of Contents Introduction 3 1 mpac.h 4 1.1 MPAC_SUCCESS 4 1.2 MPAC_FAILURE 4 1.3 MPAC_NULL 4 1.4 mpac_min 4 1.5 mpac_max 4 1.6 mpac_g 5 1.7 mpac_m 5 1.8 mpac_k 5 1.9 mpac_handle
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 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 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 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 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 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 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 informationApplication Programming Interfaces
Application Programming Interfaces Stefan D. Bruda Winter 2018 SYSTEM CALLS Machine 1 Machine 2 Application 1 Application 3 Application 4 Application 5 Application 2 API (system functions) API (system
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 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 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 informationOutline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014
Outline Distributed Computing Systems Sockets Socket basics Socket details (TCP and UDP) Socket options Final notes Socket Basics (1 of 2) An end-point for an Internet network connection what application
More informationThe Socket Interface. Socket and Socket Library
The Socket Interface Client and server use the transport protocol to communicate. When it interacts with protocol, an application must specify :whether it is a server or a client (that is, wether it will
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 informationLecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation
Lecture 2 Outline Wireshark Project 1 posted, due in a week Lab from a different textbook Work through the lab and answer questions at the end Chapter 1 - Foundation 1.1 Applications 1.2 Requirements 1.3
More informationGood Luck! Marking Guide. APRIL 2014 Final Exam CSC 209H5S
APRIL 2014 Final Exam CSC 209H5S Last Name: Student #: First Name: Signature: UNIVERSITY OF TORONTO MISSISSAUGA APRIL 2014 FINAL EXAMINATION CSC209H5S System Programming Daniel Zingaro Duration - 3 hours
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 informationOverview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions
Overview Last Lecture Daemon processes and advanced I/O functions This Lecture Unix domain protocols and non-blocking I/O Source: Chapters 15&16&17 of Stevens book Unix domain sockets A way of performing
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 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 informationProcesses communicating. Network Communication. Sockets. Addressing processes 4/15/2013
Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different
More informationUNIX input and output
UNIX input and output Disk files In UNIX a disk file is a finite sequence of bytes, usually stored on some nonvolatile medium. Disk files have names, which are called paths. We won t discuss file naming
More information31 ChamSys Remote Protocol Commands
31 ChamSys Remote Protocol Commands ChamSys remote protocol consists of simple commands consisting of a list parameter values separated by commas, and ending in a character A to Z (or a to z). Commands
More informationServer-side Programming
Server-side Programming CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon
More informationNetwork Communication
Network Communication Processes communicating Process: program running within a host. q within same host, two processes communicate using inter- process communica6on (defined by OS). q processes in different
More informationSocket programming in C
Socket programming in C Sven Gestegård Robertz September 2017 Abstract A socket is an endpoint of a communication channel or connection, and can be either local or over the network.
More informationNETWORK AND SYSTEM PROGRAMMING
NETWORK AND SYSTEM PROGRAMMING LAB 16 ELEMENTARY UDP SOCKETS The UDP protocol is connectionless and adds unreliability to the application. Each packet that is sent by the client or server is not acknowledged
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 information