Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network Programming with Sockets

Similar presentations


Presentation on theme: "Network Programming with Sockets"— Presentation transcript:

1 Network Programming with Sockets
Reading: Chapter 27 Fall 2004 FSU CIS 5930 Internet Protocols

2 FSU CIS 5930 Internet Protocols
Sockets A common/popular network programming interface to access transport protocols Data structures Functions Fall 2004 FSU CIS 5930 Internet Protocols

3 FSU CIS 5930 Internet Protocols
Socket addresses typedef unsigned short sa_family_t; struct sockaddr { sa_family_t sa_family; char sa_data[14]; }; struct in_addr { __u32 s_addr; struct sockaddr_in { sa_family_t sin_family; /* Address family */ unsigned short int sin_port; /* Port number */ struct in_addr sin_addr; /* Internet address */ /* Pad to size of `struct sockaddr'. */ unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) – sizeof(unsigned short int) – sizeof(struct in_addr)]; Fall 2004 FSU CIS 5930 Internet Protocols

4 Socket operations Fall 2004 FSU CIS 5930 Internet Protocols socket()
listen() bind() accept() close() connect() Connection establishment Data exchange Server Client read() recv() recvfrom() readv() recvmsg() write() send() sendto() writev() sendmsg() Fall 2004 FSU CIS 5930 Internet Protocols

5 Byte ordering methods Little-endian vs. big-endian Functions
htonl(), htons(), ntohl(), ntohs() Most significant byte 0xAA Least significant byte 0xBB Least significant byte 0xBB Most significant byte 0xAA 0x1000 0x1001 Big-Endian (Network-Byte-Order) Little-Endian Memory address Fall 2004 FSU CIS 5930 Internet Protocols

6 Functions to handle Internet addresses
Dotted decimal notation vs. Internet address (in_addr) inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton() Others getpeername(), get the IP address of the peer gethostname(), get name of local host gethostbyname(), get host IP address, given name Fall 2004 FSU CIS 5930 Internet Protocols


Download ppt "Network Programming with Sockets"

Similar presentations


Ads by Google