36-NetworkTCPIP-Deta - CS 241 Spring 2008 System Programming TCP Programming II TCP/IP Protocol Learning Objectives UDP Trivial Example TCP Code

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 241 Spring 2008 System Programming 1 TCP Programming II TCP/IP Protocol Learning Objectives Example TCP Code TCP/IP Packets and PDUs Host name resolution Lawrence Angrave
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Socket Trivia In Most code examples: int s = socket( AF_INET , SOCK_STREAM , 0 ); Purist Police: int s = socket( PF_INET , SOCK_STREAM , 0 ); <socket.h> /* Protocol families, same as address families. */ #define AF_INET 2 #define PF_INET AF_INET
Background image of page 2
3 Sockaddr structures struct sockaddr { unsigned short sa_family; /* = AF_xxx */ char sa_data[14]; /* 14 bytes of protocol addr*/ }; struct sockaddr_in { short sin_family; // e.g. AF_INET unsigned short sin_port; // e.g. htons(3490) struct in_addr sin_addr ; // see struct in_addr, below char sin_zero[8]; // zero this if you want to }; struct in_addr { (Exists due to Historical Reasons) in_addr_t s_addr; /* 4byte IP address in network byte order */ };
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 hostent* hp= gethostbyname(. .) struct hostent { char *h_name; official cannonical)name of host char **h_aliases; ptr to array of ptrs of alias names int h_addrtype; host address type: AF_INET int h_length; length of address: 4 bytes char **h_addr_list; ptr to array of ptrs with IPv4 address structs, null terminated }; Plan: copy 4 bytes from hp->h_addr_list[0] to mysockaddr_in.sin_addr.s_addr IPv6 : we will need getaddrinfo() and getnameinfo()
Background image of page 4
5 bind clients skip bind call; don’t care which local port and Ethernet card port 0? port 80000?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Brain Teasers 1. Which socket call ( socket, bind, listen,accept,connect ) converts a socket from an active to a passive socket? 2. What happens if you use connect on a UDP (SOCK_DGRAM socket)?
Background image of page 6
7 Internet Protocol Physical Layer Physical medium, optical cables, wireless medium to move data over Network Access Layer (MAC – Medium Access Control)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/04/2008 for the course CS 241 taught by Professor Systemsprogramming during the Spring '08 term at University of Illinois at Urbana–Champaign.

Page1 / 22

36-NetworkTCPIP-Deta - CS 241 Spring 2008 System Programming TCP Programming II TCP/IP Protocol Learning Objectives UDP Trivial Example TCP Code

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online