openframeworks / openframeworks/openFrameworks

add option in ofxTCPSettings to allow TCP_NODELAY

Open
#7,603 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

I have an OF app that is sending X number of bytes to an ESP32 client at 25fps.
If the framerate is above 5fps the server sometimes joins data sends in to a single transmition. So instead of receiving X number of bytes. I get a multiple like 2x or higher in faster transmition rates.
This occurs because TCP has TCP_NODELAY Option enabled by default. This may not be an "issue" for everyone but was definitely a problem for my application.
I resolved this by adding the following lines of code into the Create() function in ofxTCPManager.cpp when the tcp connection is being made:

int enable=1;
if (setsockopt(m_hSocket,IPPROTO_TCP,TCP_NODELAY,(char*)&enable,sizeof(int))< 0)	
{
	//adedd to disable no delay
}
bool ofxTCPManager::Create()
{
	if (m_hSocket != INVALID_SOCKET) return(false);
	m_closing = false;
	m_hSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_IP);
	int enable=1;
	if (setsockopt(m_hSocket,IPPROTO_TCP,TCP_NODELAY,(char*)&enable,sizeof(int))< 0)	
	{
		//adedd to disable no delay
	}
	bool ret = (m_hSocket != INVALID_SOCKET);
	if(!ret) ofxNetworkCheckError();
	return ret;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating ofxTCPSettings and the socket creation code in ofxTCPManager.cpp, especially Create(), then read how TCP connection options are currently configured. Define how the TCP_NODELAY setting should be exposed and what its default should be. Done means the option can control the socket behavior described in the issue and the connection setup remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.