





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The slides for the first help session of cs4514 b06, a course on tcp/ip socket programming at the university of texas at dallas. The session, presented by mingzhe li, covers the basics of unix network programming, tcp client and server, processing commands, and tips for finding help. The document also includes examples of tcp client and server implementation.
What you will learn
Typology: Study notes
Uploaded on 09/22/2015
1 / 37
This page cannot be seen from the preview
Don't miss anything!
Presented by Mingzhe Li lmz@cs.wpi.edu
CS4514 – TCP/IP Socket Programming
read()
connection establishment
Server (connection-oriented protocol)blocks until connection
from client
Client
socket()bind()listen()accept() read() write()
socket()connect()write()
process request
data (request)data (reply)
Socket system calls forSocket system calls forconnectionconnection-
-orientedoriented
protocol ( TCP )protocol ( TCP )
-^
-^
-^ read() / write()
-^ recv() / send()
socket() connect() read() / write()^ recv() /send()
close()
int sd; struct hostent *hp;
/ /usr/include/netdb.h /
struct sockaddr_in server;
/ /usr/include/netinet/in.h /
/ prepare a socket / if ( (sd =
socket
perror( strerror(errno) ); exit(-1);
}
/ connect to the server / if (
connect
(^ sd, (struct sockaddr*) &server, sizeof(server) ) < 0
perror( strerror(errno) ); exit(-1);
} / send/receive data / while (1) {
read/write();
} / close socket / close
( sd );
socket()^ bind()^ listen() accept()^ close() read()/write()
bind
( sd, (struct sockaddr*) &server, sizeof(server) ); listen
( sd, backlog ); while (1) {^ nsd =
accept
( sd, (struct sockaddr *) &client, sizeof(client) );
read
write
close( nsd ); } close( sd );
-^
-^
TCP message back to the Client
.”