You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* $Id: asyncsendto.h,v 1.2 2014/05/19 14:21:10 nanard Exp $ */
  2. /* MiniUPnP project
  3. * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
  4. * (c) 2006-2014 Thomas Bernard
  5. * This software is subject to the conditions detailed
  6. * in the LICENCE file provided within the distribution */
  7. #ifndef ASYNCSENDTO_H_INCLUDED
  8. #define ASYNCSENDTO_H_INCLUDED
  9. /* sendto_schedule() : see sendto(2)
  10. * schedule sendto() call after delay (milliseconds) */
  11. ssize_t
  12. sendto_schedule2(int sockfd, const void *buf, size_t len, int flags,
  13. const struct sockaddr *dest_addr, socklen_t addrlen,
  14. const struct sockaddr_in6 *src_addr,
  15. unsigned int delay);
  16. #define sendto_schedule(sockfd, buf, len, flags, dest_addr, addrlen, delay) \
  17. sendto_schedule2(sockfd, buf, len, flags, dest_addr, addrlen, NULL, delay)
  18. /* sendto_schedule() : see sendto(2)
  19. * try sendto() at once and schedule if EINTR/EAGAIN/EWOULDBLOCK */
  20. ssize_t
  21. sendto_or_schedule(int sockfd, const void *buf, size_t len, int flags,
  22. const struct sockaddr *dest_addr, socklen_t addrlen);
  23. /* same as sendto_schedule() except it will try to set source address
  24. * (for IPV6 only) */
  25. ssize_t
  26. sendto_or_schedule2(int sockfd, const void *buf, size_t len, int flags,
  27. const struct sockaddr *dest_addr, socklen_t addrlen,
  28. const struct sockaddr_in6 *src_addr);
  29. /* get_next_scheduled_send()
  30. * return number of scheduled sendto
  31. * set next_send to timestamp to send next packet */
  32. int get_next_scheduled_send(struct timeval * next_send);
  33. /* execute sendto() for needed packets */
  34. int try_sendto(fd_set * writefds);
  35. /* set writefds before select() */
  36. int get_sendto_fds(fd_set * writefds, int * max_fd, const struct timeval * now);
  37. /* empty the list */
  38. void finalize_sendto(void);
  39. #endif