






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
This lecture was delivered by Dr. Ram Sai at Jaypee University of Engineering and Technology for Computers and Network Programming course. It includes: Network, Programming, Elementary, Udp, Sockets, Tcp, Domain, Name, Streaming, Media, System, Data, Transmission
Typology: Slides
1 / 12
This page cannot be seen from the preview
Don't miss anything!







-^ UDP^ uses^ a^ simple
transmission^ model
without^ implicit hand‐shaking^ dialogues
for^ providing^ reliability, ordering,^ or^ data^ integrity. • UDP^ assumes^ that
error^ checking^ and
correction^ is either^ not^ necessary
or^ performed^ in^ the
application, avoiding^ the^ overhead
of^ such^ processing.
-^ useful^ for^ servers
answering^ small^ queries
from^ huge numbers^ of^ clients.
Unlike^ TCP,^ UDP^ is
compatible^ with packet^ broadcast^ (sending
to^ all^ on^ local^ network)
and multicasting^ (send
to^ all^ subscribers).
-^ UDP^ is^ a^ connectionless,
-^ The^ client^ does
not^ establish^ a^ connection
with the^ server.^ Instead,
the^ client^ just^ sends
a datagram^ to^ the
server^ using^ the
sendto function
-^ requires^ the^ address
of^ the^ destination
(the server)^ as^ a^ parameter. • Similarly,^ the^ server
does^ not^ accept
a^ connection from^ a^ client. • Instead,^ the^ server
just^ calls^ the^ recvfrom function,^ which^ waits
until^ data^ arrives
from some^ client. • recvfrom returns
the^ protocol^ address
of^ the client,^ along^ with
the^ datagram,^ so
the^ server^ can send^ a^ response
to^ the^ correct^ client
#include^ <sys/socket.h>ssize_t^ recvfrom(int^ sockfd,
void^ *buff,^ size_t^ nbytes,^ int
flags,^ struct^ sockaddr^ *from,
socklen_t
*addrlen);ssize_t sendto(int sockfd,^ const
void^ *buff,^ size_t nbytes,^ int flags,
const^ struct sockaddr *to, socklen_t addrlen);
Both^ return:^ number^ of^ bytes
read^ or^ written^ if^ OK,^ –1^ on
error docsity.com
-^ The^ first^ three
-^ Flag^ is^ 0.
-^ The^ final^ two^ arguments
to^ recvfrom are
similar to^ the^ final^ two^ arguments
to^ accept:^ The contents^ of^ the^ socket
address^ structure
upon return^ tell^ us^ who
sent^ the^ datagram
(in^ the^ case of^ UDP)^ or^ who^ initiated
the^ connection^
(in^ the case^ of^ TCP). • The^ final^ two^ arguments
to^ sendto are^ similar
to the^ final^ two^ arguments
to^ connect:^ We^
fill^ in^ the socket^ address^ structure
with^ the^ protocol address^ of^ where
to^ send^ the^ datagram
(in^ the case^ of^ UDP)^ or^ with
whom^ to^ establish
a connection^ (in^ the
case^ of^ TCP)
-^ Both^ functions