Search code examples
pythonsocketstcp

socket tcp package no delay


I want to send two packages one by one:

conn.send('package_1')
conn.send('package_2')

The question is it will be assembled in one package, because the interval of these to package is small. I don't want this to happen. So I found s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1), but it still doesn't work.

In client, it still receive a package like this package_1package_2

similar to this question


Solution

  • That's how TCP works. TCP is not a message protocol. If you want a message protocol, you have to implement (or choose) one.