Socket programming in C

Size: px
Start display at page:

Download "Socket programming in C"

Transcription

1 Socket programming in C Sven Gestegård Robertz <sven.robertz@cs.lth.se> September 2017 Abstract A socket is an endpoint of a communication channel or connection, and can be either local or over the network. We will now give a brief introduction to socket programming, particularly IPv4 network sockets using the C standard library. A socket can be either a server socket, accepting connections, or a client socket, connecting to a server socket. The C library functions for creating a socket are presented in Section 1. For sending and receiving data, a socket is abstracted as a file, so the same functions that are used for reading and writing normal files are used to send and receive data over a socket. The difference is how to open and set up a socket. The C library functions for reading and writing files are presented in Section 2. Section 3 shows how to open actual files, and Section 4 gives examples of how error handling can be expressed. This is a brief introduction to the topics. For further information, the reader is referred to the manual pages of the presented functions (see Section 5). 1 Sockets A socket is created using the function socket(). It can then be made a server socket with calls to bind (binding a name to the socket), listen() (make the socket a passive socket, listening for incoming connections) and accept() (which blocks until a client connects). To make it a client socket, the function connect() is used. The prototypes of the socket functions are int socket ( int domain, int type, int protocol ); where domain is the kind of socket (AF_INET for IPv4), type is the type of connection (SOCK_STREAM for a connection-based byte stream (i.e., TCP) and SOCK_DGRAM for datagram-based channel (i.e. UDP)). protocol specifices the protocol to be used with the socket. Often only one protocol exists, and 0 is used. The return value is a positive file descriptor for the created socket, or negative on error. int bind ( int fd, const struct sockaddr * addr, socklen_ t len ); where fd is the file descriptor returned by socket, addr is a pointer to a structure containing the address and len is the size (in bytes) of that structure. The actual structure type used depends on the kind of socket, so the struct sockaddr can be viewed as the superclass of the actual struct being used, but as C is not object oriented, the programmer has to do typecasts and pass the size of the actual structure as a parameter. For IPv4 connections, the actual type to use is struct sockaddr_in. 1

2 int listen ( int fd, int backlog ); where fd is the socket to use, and backlog is the size of the queue for pending connections. int accept ( int fd, struct sockaddr * addr, socklen_ t * addrlen ); where fd is the socket to use. addr and addrlen are in/out parameters where the address of the peer socket is filled in. Memory for the struct has to be allocated by the caller, and the size of the allocated memory passed. On return, addrlen contains the actual size of the address structure, and if this is larger than what was passed, the address is truncated. If NULL is passed, nothing is filled in. int connect ( int fd, const struct sockaddr * addr, socklen_ t len ); where fd is the socket, addr is the address to connect to, and len is the size of the address struct. 1.1 Closing a file descriptor When a program no longer needs to use a file (or other resource abstracted as a file, like a socket), or before terminating the program, the file must be closed, in order to release any operating system resources, locks, etc.. If a socket file descriptor is not properly closed before exiting, the next time a program tries to open that socket it may get an error that the port is in use. A file is closed with a call to int close(int fd); where fd is the file descriptor, and the return value is zero on success. On error, 1 is returned and errno is set to indicate the error. Failing to close a file descriptor may give errors that the file is in use on subsequent attempts to use the file or resource. Note that with TCP sockets, a call to close() does not direcly close the socket. As TCP is connection based, closing the socket involves synchronizing with the remote end, and it is common that this fails, rendering the socket (address/port pair) unusable until there is a timeout in the TCP implementation. To force reuse of a port number, the socket option SO_REUSEADDR can be set, using the function int setsockopt ( int fd, int level, int optname, const void * optval, socklen_ t optlen ); as follows: int val = 1; if( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof ( val ))) { perror (" setsockopt "); return -1; Note that the option value is passed as a pointer, and that it is strongly recommended to always check the return value for errors. 2

3 2 File I/O For terminal IO, sockets, and many other forms of I/O, the operating system exposes the communication channel as a file, and accessing it involves two important concepts, file descriptors are integers representing (opened) files as operating system resources, and are used for opening, closing, low-level configuration and access to the files or devices. streams are high level channels that allows sending/receiving a stream of characters. Streams provide a richer interface with formatted I/O, buffering, etc., and also abstracts the underlying resources and provides a unified interface. In POSIX, a stream is represented as a FILE *. This section describes both ways to read and write a file, but as a general hint it is recommended to use structured functions for doing output (i.e., the different fprintf() variants), but for simple tasks, it is often less error prone to use the low-level function for input (i.e, read()). One reason for that, in addition to buffering and blocking, is that the structured input functions retain the end-of-line character(s) 1 and add a terminating null to the string, whereas read() just gives the actual characters received. 2.1 Raw file access using file descriptors The low-level functions for reading and writing a file are read() and write(), which read(write) at most nbyte bytes from(to) the resource behind file descriptor fd. The prototypes are: ssize_t read ( int fd, void * buf, size_t nbyte ); ssize_t write ( int fd, const void * buf, size_t nbyte ); Please note that neither the C compiler, nor the runtime system, does any range checks, so it s up to the programmer to ensure that the size of buf is at least nbyte, or memory used by other variables may get overwritten with undefined consequences. We let examples from the manual pages illustrate the usage. The first example reads data from the file associated with the file descriptor fd into the buffer pointed to by buf. # include <sys / types.h> # include < unistd.h> char buf [20]; size_t nbytes ; ssize_t bytes_ read ; int fd; nbytes = sizeof ( buf ); bytes_ read = read ( fd, buf, nbytes ); 1 Depending on system configuration, the end-of-line (EOL) marker may be either a single newline character (\n) or a newline and a carriage return (\n\r). If you don t understand this, don t worry, just use read() and write your own input parsing. 3

4 The second example writes data from the buffer pointed to by buf to the file associated with the file descriptor fd. # include <sys / types.h> # include < string.h> char buf [20]; size_t nbytes ; ssize_t bytes_ written ; int fd; strncpy (buf, " This is a test \n", sizeof ( buf )); nbytes = strnlen ( buf ); bytes_ written = write ( fd, buf, nbytes ); Note the operator sizeof() for getting the size (in bytes) of a data type or statically known 2 array, and the convenient functions strncpy() and strnlen() (from string.h) for copying and determining the length (the lenght of the string itself, not the size of the array containing it) of a null-terminated string. To make the code portable, the integer types size_t (from sys/types.h) for unsigned sizes and ssize_t (from unistd.h) for signed sizes (used since read() and write() can return a negative value on error) are used. 2.2 Structured stream I/O Above the low-level read() and write() functions, the standard library stdio.h provides powerful functions (e.g., fprintf() and fscanf())for formatted I/O, including formatting integers numbers as decimal or hexadecimal strings, real numbers, etc. It also includes the function getc() which reads the next (unsigned) character from a stream and casts it to an int, and the function fgets() which reads a string from the stream until a newline or end of file (EOF) is encountered and stores it in a buffer Function overview The function for creating a stream from a file descriptor is FILE * fdopen ( int fd, const char * mode ); where fd is the file descriptor and mode is a string specifying the mode of access. In this course we will typically use "r+", meaning reading and writing. There is also a function int fclose ( FILE *fp ); for flushing and closing the stream fp and then closing the underlying file descriptor. Upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error. 2 That means that is works for a variable defined with a statically known size (like char buf[20]) but not objects refereced by pointers or dynamically allocated buffers. For this course, it is recommended to stick to the former method of allocating buffers. 4

5 Then we have the functions for reading one character and a line, respectively, from stream; int fgetc ( FILE * stream ) char * fgets ( char *s, int size, FILE * stream ) fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error. fgets() reads at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte (\0) is stored after the last character in the buffer. fgets returns s on success, and NULL on error or when end of file occurs while no characters have been read. EOF is a constant (or macro) defined in stdio.h, typically 1. Finally, we have the functions for formatted output(input) to(from) streams, int fprintf ( FILE * stream, const char * format, ); int fscanf ( FILE * stream, const char * format, ); where stream is the stream to access, format is a string specifying the format of the data, and the remaining arguments () depend on the format string Formatted output example Before going through the format specification in detail, we will first give some examples of conversion using printf() (which writes to standard out, the stream connected to the terminal the program is executed in. I.e., printf() is a shorthand for fprintf(stdout, )). 5

6 The program # include <stdio.h> int main () { int x =17; int y =428; int z =1; double f = 13.37; double g = ; char *s1 = " hej "; char *s2 = " hopp "; char b = 0 b ; unsigned char ub = 0 b ; printf ("x == %d\n", x); printf ("%x, %#X, %.4X, %d %u\n",x,x,x,x,x); printf ("%x, %#X, %.4X, %d %u\n",y,y,y,y,y); printf ("%#10 x, %10.2x, %s\n",x,x, s1 ); printf ("%#10 x, %10.2x, %s\n",y,y, s2 ); printf ("%#10 x, %10.2x, %s\n",z,z, " literal "); printf ("%f, %.2f, %2.2 f\n",f,f,f); printf ("%f, %.9f, %2.2 f\n",g,g,g); // note the difference between signed and unsigned. printf ("%x, %d, %u\n", b,b,b); printf ("%x, %d, %u\n", ub,ub,ub ); printf ("%x, %d, %u\n", ( unsigned char ) b,( unsigned char ) b, ( unsigned char ) b); return 0; produces the output x == 17 11, 0X11, 0011, ac, 0X1AC, 01AC, x11, 11, hej 0x1ac, 1ac, hopp 0x1, 01, literal , 13.37, , , ffffffa5, -91, a5, 165, 165 a5, 165, 165 Note the difference between signed and unsigned integer types as indicated in the code, and how sign extension changes the value of a variable that is assigned a constant with the most significant bit set. If the reader doesn t understand the details of that it is fine (but do make sure to use unsigned types when dealing with bit patterns etc.). However, we encourage the interested student to work out the details as it gives valuable insight into two s complement arithmetics. That is quite valuable to the Java programmer, as Java unfortunately does not have unsigned data types and therefore requires great care when doing bit operations. 6

7 2.2.3 The format specification The format string is made up of ordinary characters, which are copied as is, and conversion specifications, which causes conversion of the corresponding argument (defined by the order). A conversion specification begins with a % and ends with a characher, where the most common ones are character d,i x,x u c f s argument type, convert to/from signed decimal notation unsigned hexadecimal notation unsigned decimal notation single character (converted to unsigned char) double in decimal notation [-]mmmm.dddd char* (null terminated string) The conversion specifications also take optional arguments, placed between the % and the conversion character. They are, in order A minus sign, making the converted argument left adjusted. #, specifying an alternate form. For x,x it means printing the 0x prefix, for f it means always printing the decimal point even if no digits follow it. For others, refer to the manual page. A number specifying the minimum field width. A period, separating the width from the precision A number specifying the precision. The meaning depends on the conversion type; for floating point values it sets the number of decimals, for integer the minimum number of digits, and for strings the maximum number of characters to be printed. An h if an interger is to be printed as a short or an l if as a long. Please note that fprintf() and fscanf() uses the format string to decide the number of arguments that follow and their types. If they don t match the result is undefined. There are also similar functions for doing the same formatting operations on a string rather than a stream, that may be quite convenient: int sprintf ( char *str, const char * format, ); int snprintf ( char * str, size_t size, const char * format, ); int sscanf ( FILE * stream, const char * format, ); The difference between sprintf() and snprintf() is that the latter takes the size of the destination, str, as an argument and writes at most size bytes (including the terminating null byte ( \0 ))to str. As C has no range checking, in order to avoid buffer overflows and hard to find errors sprintf() should be avoided in favour of snprintf(). 7

8 3 Opening a file We have seen how the file abstraction is used for sockets. To access an actual file, it must first be opened by calling a function open, with the prototype int open(const char *path, int oflag); where path is a string with the path to the file, and oflag is an integer whose bits represent different modes of opening, creation and access to the file. The return value is the file descriptor or -1 if an error occurred. Values for oflag are constructed by a bitwise-inclusive OR of flags defined in i header file (<fcntl.h>). Applications shall specify exactly one of these three values (file access modes) O_RDONLY Open for reading only. O_WRONLY Open for writing only. O_RDWR Open for reading and writing. In addition to that, more flags can be set. Most of them define how files shall be created, if existing files shall be overwritten or appended to, etc.. As examples of the kind of behaviour that is controlled by flags we have O_DIRECTORY which causes open to fail if path is not a directory. O_NOFOLLOW which causes open to fail if path is a symbolic link. Please see the manual pages for further information. 4 Error handling examples The following snippet shows how a file is opened and closed, including error handling. const char * filename = "/ path /to/ file "; int fd; fd = open ( filename, O_ RDONLY ); if ( fd <0) { // an error occurred. Print message and exit program perror (" Failed to create socket "); exit ( -1); // if( close (fd) <0 ) { perror (" Failed to close socket "); If the return value of open or close is negative, an error has occurred. perror() is a function printing a message on the standard error output, describing the last error encountered during a call to a system or library function 3. 3 The mechanism behind this is that when an error occurs, the failing function writes an error code to the global variable errno, and perror() reads that variable and prints a humanreadable message corresponding to the error code. The error codes are defined in errno.h. 8

9 Another common pattern for handling errors during setup is the use of goto. As C doesn t have exceptions, if an error occurs during initialization, goto is used to jump out to the corresponding cleanup section of a function. Thus, something that could be written using nested try blocks in java like void example ( int port ) throws SomeException { try { ServerState server = createsocket (); try { server. bindandlisten ( port ); server. run (); finally { server. closesocket (); catch { java. net. SocketException e) { throw new SomeException ( e); is often written using goto in C: int example ( int port ) { struct server_ state server ; int result =0; init_ server (& server ); if( create_socket (& server )) { result = FAILED_ TO_ CREATE_ SOCKET ; goto no_ server_ socket ; if( bind_and_listen (& server, port )) { result = FAILED_ TO_ LISTEN ; goto failed_ to_ listen ; run_server (& server ); failed_ to_ listen : if( close ( state.fd )) perror (" closing fd "); no_ server_ socket : return result ; where the functions create_socket() and bind_and_listen(), and the error codes FAILED_TO_CREATE_SOCKET and FAILED_TO_LISTEN are defined elsewhere in the application. Please note that in C, goto can only be used to jump within a function, unlike Java exceptions. To communicate errors across function calls, the return value is normally used. 9

10 5 Manual pages On a unix-like system (including GNU/Linux and MacOS X), the documentation of system calls and the functions in the C library is accessible through the man system. For instance, to read the documentation for the socket function, give the command > man socket which will open a pager with the manual page: SOCKET( 2 ) Linux Programmer s Manual NAME s o c k e t c r e a t e an endpoint f o r communication SYNOPSIS #i n c l u d e <s y s / t y p e s. h> / See NOTES / #i n c l u d e <s y s / s o c k e t. h> i n t s o c k e t ( i n t domain, i n t type, i n t p r o t o c o l ) ; DESCRIPTION s o c k e t ( ) c r e a t e s an endpoint f o r communication and r e t u r n s a d e s c r i p t o r. Important sections of a manual include RETURN VALUE and ERRORS. RETURN VALUE On s u c c e s s, a f i l e d e s c r i p t o r f o r the new s o c k e t i s r e t u r n e d. On e r r o r, 1 i s returned, and e r r n o i s s e t a p p r o p r i a t e l y. At the end of the page is the section SEE ALSO, which contains pointers to related man pages: SEE ALSO a c c e p t ( 2 ), bind ( 2 ), connect ( 2 ), f c n t l ( 2 ), getpeername ( 2 ), getsockname ( 2 ), g e t s o c k o p t ( 2 ), i o c t l ( 2 ), l i s t e n ( 2 ), read ( 2 ), r e c v ( 2 ), s e l e c t ( 2 ), send ( 2 ), shutdown ( 2 ), s o c k e t p a i r ( 2 ), w r i t e ( 2 ), g e t p r o t o e n t ( 3 ), i p ( 7 ), s o c k e t ( 7 ), tcp ( 7 ), udp ( 7 ), unix ( 7 ) Note the names, e.g., socket(2), where (2) means that the page is in section 2 of the manual. For some names, (e.g., write) there is a command in section 1 of the manual with the same name, and the command man write will show the first match. The section is specified before the name to look up (or, on some systems, with the option -s <section>. To get the man page for the function write(2), use the command > man 2 write or > man -s 2 write In the manual, section 2 contains system calls, and section 3 contains library functions (like, for instance, printf). If you don t know what section the manual page is in, the option -a gives all man pages with the given name. For more details, see man(1). Manual pages that give an overview of a topic can be found in section 7 (miscellaneous), for instance socket(7) which documents the socket interface, and ip(7) which describes the IPv4 implementation (i.e. TCP and UDP sockets). 10

Communication. Serial port programming

Communication. Serial port programming Applied mechatronics Communication. Serial port programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2017 Outline 1 Introduction 2 Terminal I/O programming

More information

CSE 124 Discussion Section Sockets Programming 10/10/17

CSE 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 information

A brief introduction to C programming for Java programmers

A brief introduction to C programming for Java programmers A brief introduction to C programming for Java programmers Sven Gestegård Robertz September 2017 There are many similarities between Java and C. The syntax in Java is basically

More information

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

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 information

CSE 410: Systems Programming

CSE 410: Systems Programming CSE 410: Systems Programming Input and Output Ethan Blanton Department of Computer Science and Engineering University at Buffalo I/O Kernel Services We have seen some text I/O using the C Standard Library.

More information

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

Lecture 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 information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

CSC209H 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 information

Tutorial on Socket Programming

Tutorial 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 information

Networked Applications: Sockets. End System: Computer on the Net

Networked 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 information

Programming refresher and intro to C programming

Programming refresher and intro to C programming Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2

More information

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

Socket 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 information

CSMC 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 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 information

Section 3: File I/O, JSON, Generics. Meghan Cowan

Section 3: File I/O, JSON, Generics. Meghan Cowan Section 3: File I/O, JSON, Generics Meghan Cowan POSIX Family of standards specified by the IEEE Maintains compatibility across variants of Unix-like OS Defines API and standards for basic I/O: file, terminal

More information

Group-A Assignment No. 6

Group-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 information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX

More information

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

CSci 4061 Introduction to Operating Systems. Input/Output: High-level CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device

More information

CSE 333 Section 8 - Client-Side Networking

CSE 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 information

UNIX System Programming

UNIX System Programming File I/O 경희대학교컴퓨터공학과 조진성 UNIX System Programming File in UNIX n Unified interface for all I/Os in UNIX ü Regular(normal) files in file system ü Special files for devices terminal, keyboard, mouse, tape,

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information

Computer Networks Prof. Ashok K. Agrawala

Computer 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 information

Elementary TCP Sockets

Elementary 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 information

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! Lecture 5 Overview! Last Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! This Lecture! Socket options! Source: Chapter 7 of Stevens book! Elementary UDP sockets! Source: Chapter 8 of Stevens

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor

More information

Socket Programming for TCP and UDP

Socket 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 information

UNIT IV- SOCKETS Part A

UNIT IV- SOCKETS Part A 1. Define sockets - SOCKETS Part A A socket is a construct to provide a communication between computers. It hides the underlying networking concepts and provides us with an interface to communicate between

More information

Systems Programming. 08. Standard I/O Library. Alexander Holupirek

Systems Programming. 08. Standard I/O Library. Alexander Holupirek Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:

More information

Oral. Total. Dated Sign (2) (5) (3) (2)

Oral. 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 information

The Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4

The 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 information

Operating systems. Lecture 7

Operating systems. Lecture 7 Operating systems. Lecture 7 Michał Goliński 2018-11-13 Introduction Recall Plan for today History of C/C++ Compiler on the command line Automating builds with make CPU protection rings system calls pointers

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-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 information

System Programming. Sockets

System 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

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line Operating Systems Lecture 06 System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line March 04, 2013 exec() Typically the exec system call is

More information

Goals of this Lecture

Goals of this Lecture I/O Management 1 Goals of this Lecture Help you to learn about: The Unix stream concept Standard C I/O functions Unix system-level functions for I/O How the standard C I/O functions use the Unix system-level

More information

UNIX 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. 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 information

CS307 Operating Systems Processes

CS307 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 information

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. 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 information

Programming with TCP/IP. Ram Dantu

Programming 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 information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

Networked 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 information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

File Descriptors and Piping

File Descriptors and Piping File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors

More information

Naked C Lecture 6. File Operations and System Calls

Naked C Lecture 6. File Operations and System Calls Naked C Lecture 6 File Operations and System Calls 20 August 2012 Libc and Linking Libc is the standard C library Provides most of the basic functionality that we've been using String functions, fork,

More information

Network 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 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 information

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron MSc Integrated Electronics Networks Assignment Investigation of TCP/IP Sockets and Ports Gavin Cameron Introduction TCP and IP (Transmission Control Protocol / Internet Protocol) are two protocols from

More information

Socket Programming TCP UDP

Socket 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 information

File IO and command line input CSE 2451

File 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 information

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

sottotitolo 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 information

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Lecture 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 information

ECE 435 Network Engineering Lecture 2

ECE 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 information

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Ports 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 information

Standard C Library Functions

Standard C Library Functions Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

What Is Operating System? Operating Systems, System Calls, and Buffered I/O. Academic Computers in 1983 and Operating System

What Is Operating System? Operating Systems, System Calls, and Buffered I/O. Academic Computers in 1983 and Operating System What Is Operating System? Operating Systems, System Calls, and Buffered I/O emacs gcc Browser DVD Player Operating System CS 217 1 Abstraction of hardware Virtualization Protection and security 2 Academic

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Network Programming in C. Networked Systems 3 Laboratory Sessions and Problem Sets

Network 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 information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 13 si 14: Unix interface for working with files. Cristina Nita-Rotaru Lecture 13/Fall 2013 1 Working with Files (I/O) File system: specifies how the information is organized

More information

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Sockets. 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 information

A Client-Server Exchange

A 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 information

EEC-484/584 Computer Networks

EEC-484/584 Computer Networks EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer

More information

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as

More information

CSC 271 Software I: Utilities and Internals

CSC 271 Software I: Utilities and Internals CSC 271 Software I: Utilities and Internals Lecture 13 : An Introduction to File I/O in Linux File Descriptors All system calls for I/O operations refer to open files using a file descriptor (a nonnegative

More information

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

Network Socket Programming - 3 BUPT/QMUL

Network 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 information

STUDY OF SOCKET PROGRAMMING

STUDY 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 information

UNIX System Calls. Sys Calls versus Library Func

UNIX System Calls. Sys Calls versus Library Func UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the

More information

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Socket 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 information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

Sockets 15H2. Inshik Song

Sockets 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 information

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

Context. 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 information

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection 1 Files 1.1 File functions Opening Files : The function fopen opens a file and returns a FILE pointer. FILE *fopen( const char * filename, const char * mode ); The allowed modes for fopen are as follows

More information

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C 2017-03-06 Processes often need to communicate CSCB09: Software Tools and Systems Programming E.g. consider a shell pipeline: ps wc l ps needs to send its output to wc E.g. the different worker processes

More information

What s an API? Do we need standardization?

What s an API? Do we need standardization? Network Interface z The network protocol stack is a part of the OS z Need an API to interface applications to the protocol stack. What s an API? Do we need standardization? z The socket interface is the

More information

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags Outline SWE 545 Socket Options POSIX name/address conversion Out-of-Band Data Advanced Socket Programming 2 Socket Options Various attributes that are used to determine the behavior of sockets Setting

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu cs@ecnu Annoucement Next Monday (28 Sept): We will have a lecture @ 4-302, 15:00-16:30 DON'T GO TO THE LABORATORY BUILDING! TA email update: ecnucchuang@163.com ecnucchuang@126.com

More information

ECE 435 Network Engineering Lecture 2

ECE 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 information

Network Socket Programming - 3 BUPT/QMUL

Network 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 information

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Hybrid 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 information

Network programming(ii) Lenuta Alboaie

Network programming(ii) Lenuta Alboaie Network programming(ii) Lenuta Alboaie adria@info.uaic.ro 1 Content let s remember: iterative TCP client/server UDP client/server model I/O primitives Advanced programming aspects in Internet socket API

More information

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST 2011 EXAMINATIONS CSC 209H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: one two-sided 8.5x11

More information

UNIX input and output

UNIX 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 information

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

PA #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 information

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Types (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 information

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

A 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 information

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

How 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 information

SOCKET 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 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 information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

CSE 333 Lecture 16 - network programming intro

CSE 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 information

SWEN-250 Personal SE. Introduction to C

SWEN-250 Personal SE. Introduction to C SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the

More information

Sockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018

Sockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018 Sockets and Parallel Computing CS439: Principles of Computer Systems April 11, 2018 Last Time Introduction to Networks OSI Model (7 layers) Layer 1: hardware Layer 2: Ethernet (frames) SAN, LAN, WAN Layer

More information

CSE 333 Lecture 8 - file and network I/O

CSE 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 information

Network programming(i) Lenuta Alboaie

Network 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 information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

TCP: Three-way handshake

TCP: 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 information

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

CS 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 information

Files. Eric McCreath

Files. Eric McCreath Files Eric McCreath 2 What is a file? Information used by a computer system may be stored on a variety of storage mediums (magnetic disks, magnetic tapes, optical disks, flash disks etc). However, as a

More information

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

Socket 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 information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. 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 information

CS 640: Computer Networking

CS 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 information