add: tt.tv_usec = 0; tt.tv_sec = timeout; FD_ZERO(&ins); FD_SET(sock, &ins);  select(sock + 1, &ins, NULL, NULL, (timeout > 0 ? &tt : NULL)); if (FD_ISSET(sock, &ins)) { char buf[1]; struct sockaddr_in ix; int slen = sizeof(ix);  ret = recvfrom(sock, buf, sizeof(buf), MSG_PEEK, (struct sockaddr *)&ix, &slen); debug_v("received packet from %s:%d, using as default dest", netcat_inet_ntop(&ix.sin_addr), ntohs(ix.sin_port)); connect(sock, (struct sockaddr *)&ix, slen);   return sock; } }   return -1;
context: int core_udp_listen(struct in_addr *local_host, unsigned short local_port){  int ret, sock;  struct sockaddr_in myaddr;  debug_v("core_udp_listen(local_host=%p, local_port=%hu)",	  (void *)local_host, local_port);  sock = netcat_socket_new(PF_INET, SOCK_DGRAM);  if (sock < 0)    return sock;  myaddr.sin_family = AF_INET;  myaddr.sin_port = htons(local_port);  if (local_host)    memcpy(&myaddr.sin_addr, local_host, sizeof(myaddr.sin_addr));  else    memset(&myaddr.sin_addr, 0, sizeof(myaddr.sin_addr));  ret = bind(sock, (struct sockaddr *)&myaddr, sizeof(myaddr));  if (ret < 0)    return -11;  return sock;}				/* end of core_udp_listen() */