I did a corresponding test in native C with the same port:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
int main() {
struct sockaddr_in address;
int desc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
int retval;
if (desc == -1) {
perror("socket() failed");
return 10;
}
address.sin_family = AF_INET;
address.sin_port = htons(21000);
address.sin_addr.s_addr = INADDR_ANY;
retval = bind(desc, (struct sockaddr*) &address, sizeof(address));
if (retval != 0) {
perror("bind() failed");
return 20;
}
retval = listen(desc, 5);
if (retval == -1) {
perror("listen() failed");
return 35;
}
printf("Socket is listening\n");
struct sockaddr_in accept_addr;
int size = sizeof(accept_addr);
int accept_desc = accept(desc, (struct sockaddr*) &accept_addr, &size);
if (accept_desc == -1) {
perror("accept failed");
return 30;
}
close(desc);
return 0;
}
Need I say that it works without delay? After the listen() call, the port is open in a “netstat -l -n --inet”.
BTW, blahblahblah you’ve probably debugged a lot of networking applications, and I’m curious as to which tools you’re using to simulate different network environments? Specifically, I’d like to specify the mean lag, bandwidth and packet loss on my ethernet devices - 100 Mbit LAN testing is rather far from the rogue internet environment.