1 /* $Id: asyncsendto.h,v 1.2 2014/05/19 14:21:10 nanard Exp $ */
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 */
8 #ifndef ASYNCSENDTO_H_INCLUDED
9 #define ASYNCSENDTO_H_INCLUDED
11 /* sendto_schedule() : see sendto(2)
12 * schedule sendto() call after delay (milliseconds) */
14 sendto_schedule2(int sockfd
, const void *buf
, size_t len
, int flags
,
15 const struct sockaddr
*dest_addr
, socklen_t addrlen
,
16 const struct sockaddr_in6
*src_addr
,
19 #define sendto_schedule(sockfd, buf, len, flags, dest_addr, addrlen, delay) \
20 sendto_schedule2(sockfd, buf, len, flags, dest_addr, addrlen, NULL, delay)
22 /* sendto_schedule() : see sendto(2)
23 * try sendto() at once and schedule if EINTR/EAGAIN/EWOULDBLOCK */
25 sendto_or_schedule(int sockfd
, const void *buf
, size_t len
, int flags
,
26 const struct sockaddr
*dest_addr
, socklen_t addrlen
);
28 /* same as sendto_schedule() except it will try to set source address
31 sendto_or_schedule2(int sockfd
, const void *buf
, size_t len
, int flags
,
32 const struct sockaddr
*dest_addr
, socklen_t addrlen
,
33 const struct sockaddr_in6
*src_addr
);
35 /* get_next_scheduled_send()
36 * return number of scheduled sendto
37 * set next_send to timestamp to send next packet */
38 int get_next_scheduled_send(struct timeval
* next_send
);
40 /* execute sendto() for needed packets */
41 int try_sendto(fd_set
* writefds
);
43 /* set writefds before select() */
44 int get_sendto_fds(fd_set
* writefds
, int * max_fd
, const struct timeval
* now
);
47 void finalize_sendto(void);