views:

295

answers:

4

Hey hi guys, 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?

+3  A: 

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.

Daniel G
A: 

i think they are not at the same level, if you want to manipulate the raw package, take a look at dpkt & scapy.

Dyno Fu
A: 

you can see here under for reference.

ghostdog74
+1  A: 

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.

Remy