Lecture 8 - Socket Programming I

Lecture 8 - Socket Programming I - Socket Programming...

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

View Full Document Right Arrow Icon
Socket Programming
Background image of page 1

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

View Full DocumentRight Arrow Icon
Connection types TCP connection-oriented UDP connectionless
Background image of page 2
Transmission Control Protocol: TCP Reliable connection oriented protocol Acknowledgment of received packets Datagram ordering Implicit rate control No support for multicast and broadcast Not ideal for multimedia services Operates with IP: TCP/IP
Background image of page 3

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

View Full DocumentRight Arrow Icon
Transport Protocol Network/MAC Application Layer P1 P2 P3 Transport Layer P1 P2 Network/MAC Router/ Switch Application Layer Host A Host B Server Client
Background image of page 4
TCP Datagram Encapsulation TCP Header TCP Data Area IP Data Area IP Header Frame Data Area Frame Header
Background image of page 5

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

View Full DocumentRight Arrow Icon
TCP/IP Client Socket Primitives Socket Connect Send/Receive Close
Background image of page 6
TCP/IP Server Socket Primitives Socket Bind Listen Accept Send/Receive Close
Background image of page 7

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

View Full DocumentRight Arrow Icon
TCP/IP Server Socket Primitives socket bind listen accept send/ receive close
Background image of page 8
TCP/IP Client Socket Primitives socket connect send/ receive close
Background image of page 9

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

View Full DocumentRight Arrow Icon
socket SYNOPSIS #include <sys/types.h> #include <sys/socket.h> int socket(int domain, int type, int protocol); The socket function creates a communication endpoint and returns a file descriptor The domain parameter specifies a communication domain selects the protocol family
Background image of page 10
socket Common values for domain PF_INET IPv4 Internet protocols PF_INET6 IPv6 Internet protocols type specifies the communication semantic Common values for type SOCK_STREAM Provides sequenced, reliable, two-way, connection- based byte streams. TCP sockets
Background image of page 11

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

View Full DocumentRight Arrow Icon
socket Common values for type SOCK_DGRAM Supports datagrams (connectionless, unreliable messages of a fixed maximum length). UDP sockets The protocol specifies a particular protocol to be used with the socket Normally set to 0 since there is only protocol implemented (tcp or udp) Return value is >0 if successful, -1 and errno is set if error.
Background image of page 12
Example int listenfd; listenfd = socket(PF_INET,SOCK_STREAM,0); if(listenfd<0) { perror("socket: "); return -EIO; }
Background image of page 13

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

View Full DocumentRight Arrow Icon
bind SYNOPSIS #include <sys/types.h> #include <sys/socket.h> int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); bind gives the socket sockfd the local
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 42

Lecture 8 - Socket Programming I - Socket Programming...

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

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