Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum packet size a python socket can handle?

i am new to network programming in python. I wanted to know that what is the maximum size packet we can transmit or receive on python socket? and how to find out it?

like image 344
Rise Avatar asked Jan 19 '10 04:01

Rise


2 Answers

The actual amount of data that can be sent in a single packet depends on what the Maximum Transmission Unit (MTU) is for the protocol you're using. Read the Wikipedia article for more information.

This is generally something you don't have to worry about, though - if you send a TCP packet that's too big, the operating system will fragment it (turn it into multiple packets) for you and it will be reassembled at the host.

By the way, Python's socket library uses the operating system's sockets, so it's nothing particular to Python.

like image 81
Daniel G Avatar answered Nov 01 '22 12:11

Daniel G


I don't think there's any Python-specific limits. UDP packets have a theoretical limit of circa 65kb and TCP no upper limit, but you'll have flow control problems if you use packets much more than a few kilobytes.

like image 43
Remy Avatar answered Nov 01 '22 11:11

Remy