Disable Nagle (TCP_NODELAY) mbeb 5.15


Is there some way to disable nagle algorithm (is it even enabled?) on a tcp socket with mbed os 5.15? I see sockets provide the setsockopt method but I cannot find a reference to which options are available and whether or not nagle can be disabled via this function?

afaik no delay is the default setting.

thanks. Im getting an “error: use of undeclared identifier ‘TCP_NODELAY’” when trying to use those defines despite including “sockets.h”. Am I doing something wrong?

this was the lwip define, the mbed api uses:

There is no TCP_NODELAY, I remember that I have searched for this also, but I cannot find the init or default now. But I’m sure its nagle disabled.

ok thanks for the very fast reply :slight_smile:

The issue I’m having is that my TCP communication (my board listens for a connection) occasionally responds slower than regular (300ms vs 5ms). The actual processing time of the request however is quite low, so Im sure the issue must be on the network somehow. Does this sound like an issue that could be coming from the board, due to some configuration/buffer issue? Or does a client side issue sound more likely (Desktop application)

You’re welcome, you can analyze such problems with WireShark.
Another reason for a delay can be on the receiver side: when you send small chunks of data, the receiving side can wait with the ACK until more data comes in or a timeout expires. This timeout is OS dependent, but now usally about 5…40 ms. This feature is called delayed ACK and the sender cannot influence the receivers behaviour.