elf1984
elf1984

Reputation: 299

Python Socket programming (TCP vs. UDP)

I'm planning to design a server that receives data from multiple clients, the server don't need to send anything back to the client, though STATUS_OK is still cool but not necessary.

I know the basics of Python socket module, twisted framework but my question is, should i use UDP or TCP? The client that need to stay connected at all.

I hope you guys understand my question, thank you for your wonderful help here

Upvotes: 4

Views: 3816

Answers (4)

pajm
pajm

Reputation: 1838

I would use TCP in your situation, but it's hard to tell what the specifics of your needs are. TCP is in most cases a better protocol because it's much more reliable. Data is very rarely lost in TCP, however this does slow it down a bit. Since you're not sending anything back to the client, the fact that TCP is a streaming protocol shouldn't really matter too much.

So I'd just go with TCP.

Upvotes: 0

Glyph
Glyph

Reputation: 31860

You should always use TCP until you have a performance problem that you know can be mitigated with UDP. TCP is easier to understand when it fails.

Upvotes: 4

PAStheLoD
PAStheLoD

Reputation: 995

For how long will one client be connected to the server? How many concurrent connections are you planning to handle? If there will be very short bursts of data for a lot of clients, then you should go with UDP. But chances are, TCP will do just fine initially.

Upvotes: -1

Brendan Long
Brendan Long

Reputation: 54242

Can you afford to lose messages? If yes, use UDP. Otherwise use TCP. It's what they're designed for.

Upvotes: 2

Related Questions