















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
An introduction to the fundamental concepts of tcp and udp sockets, which are the building blocks of network programming. It covers the differences between connection-oriented (tcp) and connectionless (udp) sockets, and explains the key functions and steps involved in setting up and using both types of sockets. Two example programs that demonstrate how to implement a simple 'hello world' application using tcp and udp sockets, respectively. By studying this document, readers can gain a solid understanding of the core principles and practical implementation of network communication using sockets, which is a crucial skill for any developer working on networked applications.
Typology: Thesis
1 / 23
This page cannot be seen from the preview
Don't miss anything!
IP hardware TCP UDP application sockets IP hardware TCP UDP application sockets
socket() bind() listen() accept() send() recv() close() socket() connect() send() recv() close()
socket() bind() listen() accept() send() recv() close() socket() connect() send() recv() close()
socket() bind() listen() accept() send() recv() close() socket() connect() send() recv() close()
socket() bind() listen() accept() send() recv() close() socket() connect() send() recv() close()
(^) no distinction between server and client (^) no connection and unreliable (^) the same socket can be used to send/receive datagrams to/from multiple processes
socket() bind() close() socket() close() bind() recvfrom() sendto() recvfrom() socket() sendto() close()
socket() bind() close() socket() close() bind() recvfrom() sendto() recvfrom() socket() sendto() close()
socket() bind() close() socket() close() bind() recvfrom() sendto() recvfrom() socket() sendto() close()
int main () { int sockfd; /* create server-side socket */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); …
struct sockaddr_in my_addr; my_addr.sin_family = AF_INET; /*IPv4 */ my_addr.sin_addr.s_addr = htonl(INADDR_ANY); my_addr.sin_port = htons(2000); bind(sockfd, &my_addr, sizeof (my_addr)); listen(sockfd, MAX_CONNECTIONS);
struct hostent server_host; server_host = gethostbyname("localhost"); / configure the server address */ struct sockaddr_in server_addr; server_addr.sin_family = AF_INET; memcpy(&server_addr.sin_addr, server_host->h_addr, sizeof ( struct in_addr)); server_addr.sin_port = htons(PORT);