I run the following line in bash, on a VM running red hat 5:
for i in {1..100000};
do telnet 10.10.10.105 41941;
done
At some point, telnet connects to the port even though there is no one listening on it. It seems o be connecting to its self? The same issue appears when i start the client side of an application, without starting the server - the client successfully connects to the ip:port. The client looks something like this:
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(port));
addr.sin_addr.s_addr = inet_addr(hostname);
some_while_loop
{
status = ::connect(sock, (sockaddr *)&addr, sizeof(addr));
if (status == -1)
{
shutdown(sock, 2);
close(sock);
return false;
}
}
I found this article: http://web.deu.edu.tr/doc/soket/ which states in 6.2 that the connection will succeed if you to the same machine you're running on. My question is, why is this happening? Is it a hardware issue or is it a fail-safe red-hat kernel is using, or maby it's because of the port i'm using (for 1025 for example, i don't have this issue)... ?