Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCPClient connect() will return true is given an unresolvable hostname #1865

Closed
jchernus opened this issue Jul 26, 2019 · 1 comment · Fixed by #1911

Comments

@jchernus
Copy link

commented Jul 26, 2019

Bug Report

Expected Behavior

TCPClient.connect() should return false if it is unable to establish a connection with the specified ip/hostname and port.

Observed Behavior

If a bogus hostname is provided (not a URL at all, but jibberish), the connect() call returns true. It executes much quicker than if real URL was provided.

Steps to Reproduce

Ran this on an electron, OS 1.2.1. Call TCPClient connect() providing a hostname that will not resolve (enter jibberish, such as 'sdfjsdlkjfs'). Connect() will return true.

Test App

Add a basic test function, like the one below, and specify a port that you know is open on a URL of your choosing.

int LoraListener::testFunction(String value) {
	char mURL[128];
	strcpy(mURL, value.c_str());
	uint16_t mPort = 3000;

	Log.info("Connecting to %s on port %i", mURL, mPort);

	TCPClient mClient;
	return mClient.connect(mURL, mPort);
}

Calling the function, and passing jibberish, will return a 1.

References

https://docs.particle.io/reference/device-os/firmware/electron/#connect--1


@avtolstoy

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

@jchernus Thanks for submitted the issue. I've confirmed that we have mixed up return values in connect() and sometimes return non-zero error codes to indicate an error, while also returning positive values to indicate success (true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.