{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

36-NetworkTCPIP-Details - CS 241 Spring 2008 System...

Info icon This 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 TCP & UDP Trivial Example TCP Code TCP/IP Packets and PDUs Host name resolution Lawrence Angrave
Image of page 1

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

View Full Document Right 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
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 */ };
Image of page 3

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

View Full Document Right 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()
Image of page 4
5 bind clients skip bind call; don’t care which local port and Ethernet card port 0? port 80000?
Image of page 5

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

View Full Document Right 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)?
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) Exchange of data and Coordination among computers over local area network
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern