Web lists-archives.com

Unable to Accept TCP Connection




The following never prints "Hello, world!"


struct sboot_state {
    struct sockaddr_in haddr;
    struct sockaddr caddr;
    socklen_t clen;
    int sfd, cfd;
} state = { 0 };

state.haddr.sin_family = AF_INET;
state.haddr.sin_port = 2200;
state.haddr.sin_addr.s_addr = INADDR_ANY;

state.sfd = socket(AF_INET, SOCK_STREAM, 0);
if (state.sfd < 0) {
  perror("socket");
  exit(1);
}

if (bind(state.sfd, (struct sockaddr *)&state.haddr,
  sizeof(state.haddr)) < 0) {
  perror("bind");
  exit(1);
}

listen(state.sfd, 5);
state.clen = sizeof(state.caddr);
state.cfd = accept(state.sfd, (struct sockaddr *)&state.caddr,
  &state.clen);
if (state.cfd < 0) {
  perror("accept");
  exit(1);
}

printf("Hello, world!\n");


The program was allowed through the Windows firewall. Any hints?
Attempting to connect with netcat immediately fails.

Cheers,
     R0b0t1

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple