in_addr_t /* uint32_t (unsigned 32-bit int): */ in_port_t /* uint16_t (unsigned 16-bit int): */ sa_family_t /* */ uint8_t /* unsigned 8-bit int : */ struct in_addr { in_addr_t s_addr; /* normally: uint32_t */ }; struct sockaddr_in { uint8_t sin_len; /* length of structure, 16 */ sa_family_t sin_family; /* AF_INET */ in_port_t sin_port; /* 16-bit TCP or UDP port network-byte-ordered */ struct in_addr sin_addr; /* server IP addy; network-byte-ordered */ char sin_zero[8]; /* unused */ }; byteorder (Stevens pg. 77): let's say we have a 16-bit value: 01010110 10100111 then for big-endian, we'll write this: A[0] = 01010110 // write most significant byte first A[1] = 10100111 // then write 2nd most signif byte then for little-endian, we'll write this: A[0] = 10100111 // then write 2nd most signif byte 2nd to last A[1] = 01010110 // write most significant byte last =============================================== ==> order of bits within a byte DOES NOT CHANGE =============================================== ==> only the order of bytes within a multi-byte value another e.g., we have: 0x0102 big endian: first byte is 0x01, 2nd byte is 0x02 little endian: first byte is 0x02, 1st byte is 0x01 "big endian" : the big end of the multibyte value (its MSB) is stored at the starting address of the value "little endian" : the little end of the multibyte value (its LSB) is stored at the starting address of the value host byte order: whatever byte ordering is used by a given system uint16_t htons( uint16_t host16bitvalue ); uint32_t htonl( uint32_t host32bitvalue ); uint16_t ntohs( uint16_t net16bitvalue ); uint32_t ntohl( uint32_t net32bitvalue ); --- FTP --- PORT h1,h2,h3,h4,p1,p2 // h1 is highest order byte of IP addy; h2 is second highest order byte of IP addy, ... // p1 is highest order byte of port, p2 is ... --> bind(), getsockname(), --> client sends PORT command; server initiates connection back to client in order to xfer data --> FTP client opens new (passive) socket socket() bind() listen() --> client sends PORT command to server on control connection -- specifies local addy of new socket (getsockname()) --> server connects to address specified by PORT --> client sends RETR/LIST over control connection --> client accept()s server connection Type (ASCII/image) for data transfer - exe, gz files use image - text files use ASCII? - NVT ASCII: should be used to end a line of text, this is "\r\n" Look at FTP response codes. RETRIEVE (RETR) causes server to xfer a copy of the file specified PWD causes server to print working directory LIST causes server to send a directory listing if a directory is specified else if a filename is sent, server sends that file's attributes; if no file or directory name is sent, server returns contents of current working dir