Class Notes (809,510)
Canada (493,754)
CSC209H1 (41)
Karen Reid (20)


1 Page
Unlock Document

University of Toronto St. George
Computer Science
Karen Reid

Sockets int accept(int socfd,  Connection-Oriented struct sockaddr *cliaddr, socklen_t *addrlen); o blocks waiting for a connection (from the queue)  unblocks when a new connection is established o socfd is the listening socket o cliaddr is the address of the client  pass in a pointer to the struc sockaddr_in for the client o returns a new descriptor which refers to the TCP connection w/ the client  reads and writes on the connection will use the socket returned by accept()  Client side process: int socket(int family, int type, int protocol); o Create a socket with the same specifications as the server  specifies “how” they’re going to communicate int connect(int sockfd, const struct sockaddr *servaddr, socklen_t addrlen); o The kernel will choose a dynamic port and source IP address  Server side process: o Returns 0 on success and -1 on failure setting errno int socket(int family, int type, int protocol); o Initiates the TCP three-way handshake  Will block until server responds with the accept() call o family specifies protocol family for the socket  PF_INET – INET doman (IPv4) the one to be used  PF_LOCAL – UNIX domain for when there’s both processes and the same machine o type specifies the type of socket  SOCK_STREAM  usually  Others: SOCK_DGRAM (connectionless socket), SOCK_RAW o protocol set to 0 except in the case of SOCK_RAW o returns a socket descriptor int bind(int sockfd, const struct sockaddr *servaddr, socklen_t addrlen);  Sending and Receiving Data o For assigning a name to a socket o Sending text across sockets need canonical ending “\r\n” o
More Less

Related notes for CSC209H1

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.