tags:

views:

26

answers:

0

I am using raw sockets with TCP. Whenever a packet gets sent to me, my computer send a RST packet back. I tried http://udi.posterous.com/suppressing-tcp-rst-on-raw-sockets, which isn't working:

int main(void) {
  struct addrinfo *info, hints, *p;
  int status, sock;

  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;

  status = getaddrinfo(NULL, "3000", &hints, &info);
  if (status != 0) function_error("getaddrinfo", 1);

  for (p = info; p; p = p->ai_next) {
    sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if (sock == -1) continue;
    if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) continue;
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "Can't connect. Error = %d\n", errno);
    return 2;
  }
  freeaddrinfo(info);

  if (listen(sock, 10) == -1)
    function_error("listen", 3);

  while (1) sleep(60);

  close(sock);

  return 0;
}

void function_error(char *func, int code) {
  fprintf(stderr, "%s error: %d\n", func, errno);
  exit(code);
}

How can I get it to stop? Do I need to use that code in the same process I am using the raw socket in?