0% found this document useful (0 votes)
50 views7 pages

Socket Python 1

The document discusses sockets in Python's socket module. It describes the primary socket functions like socket(), bind(), listen(), accept(), connect(), and send()/recv(). It explains that TCP sockets provide reliable, in-order data transmission using these functions, while UDP is unreliable and unordered. TCP is recommended when reliability is important, while UDP may be preferable for real-time data with less reliability needs.

Uploaded by

yougab70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views7 pages

Socket Python 1

The document discusses sockets in Python's socket module. It describes the primary socket functions like socket(), bind(), listen(), accept(), connect(), and send()/recv(). It explains that TCP sockets provide reliable, in-order data transmission using these functions, while UDP is unreliable and unordered. TCP is recommended when reliability is important, while UDP may be preferable for real-time data with less reliability needs.

Uploaded by

yougab70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Python’s socket module provides an

interface to the Berkeley sockets API.


The primary socket API functions and
methods in this module are:

socket()
bind()
listen()
accept()
connect()
connect_ex()
send()
recv()
close()
TCP Sockets

Why should you use TCP? The Transmission Control


Protocol (TCP):

•Is reliable: packets dropped in the network are


detected and retransmitted by the sender.

•Has in-order data delivery: data is read by your


application in the order it was written by the sender.
TCP Sockets

Why should you use TCP? The Transmission Control


Protocol (TCP):

•Is reliable: packets dropped in the network are


detected and retransmitted by the sender.

•Has in-order data delivery: data is read by your


application in the order it was written by the sender.

we’ll create a socket object using socket.socket() and specify the socket type as socket.SOCK_STREAM
UDP Sockets

User Datagram Protocol (UDP) sockets created with


socket.SOCK_DGRAM aren’t reliable, and data read
by the receiver can be out-of-order from the
sender’s writes.
Why is this important?

Networks are a best-effort delivery system.

There’s no guarantee that your data will reach its


destination or that you’ll receive what’s been sent to
you.
sequence of
socket API
calls and data
flow for TCP

You might also like