2014-02-18 08:34:42 +00:00
|
|
|
/* $Id: $ */
|
|
|
|
/* MiniUPnP project
|
|
|
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
|
|
|
* (c) 2006-2014 Thomas Bernard
|
|
|
|
* This software is subject to the conditions detailed
|
|
|
|
* in the LICENCE file provided within the distribution */
|
|
|
|
|
|
|
|
#ifndef ASYNCSENDTO_H_INCLUDED
|
|
|
|
#define ASYNCSENDTO_H_INCLUDED
|
2017-06-11 10:52:55 +00:00
|
|
|
/* for fd_set */
|
|
|
|
#include <sys/select.h>
|
2014-02-18 08:34:42 +00:00
|
|
|
|
2014-02-25 10:07:47 +00:00
|
|
|
/* sendto_schedule() : see sendto(2)
|
|
|
|
* schedule sendto() call after delay (milliseconds) */
|
2014-02-18 08:34:42 +00:00
|
|
|
ssize_t
|
2014-05-19 14:16:53 +00:00
|
|
|
sendto_schedule2(int sockfd, const void *buf, size_t len, int flags,
|
|
|
|
const struct sockaddr *dest_addr, socklen_t addrlen,
|
|
|
|
const struct sockaddr_in6 *src_addr,
|
|
|
|
unsigned int delay);
|
|
|
|
|
|
|
|
#define sendto_schedule(sockfd, buf, len, flags, dest_addr, addrlen, delay) \
|
|
|
|
sendto_schedule2(sockfd, buf, len, flags, dest_addr, addrlen, NULL, delay)
|
2014-02-18 08:34:42 +00:00
|
|
|
|
2014-02-25 10:07:47 +00:00
|
|
|
/* sendto_schedule() : see sendto(2)
|
|
|
|
* try sendto() at once and schedule if EINTR/EAGAIN/EWOULDBLOCK */
|
2014-02-18 08:34:42 +00:00
|
|
|
ssize_t
|
|
|
|
sendto_or_schedule(int sockfd, const void *buf, size_t len, int flags,
|
|
|
|
const struct sockaddr *dest_addr, socklen_t addrlen);
|
|
|
|
|
2014-05-19 14:16:53 +00:00
|
|
|
/* same as sendto_schedule() except it will try to set source address
|
|
|
|
* (for IPV6 only) */
|
|
|
|
ssize_t
|
|
|
|
sendto_or_schedule2(int sockfd, const void *buf, size_t len, int flags,
|
|
|
|
const struct sockaddr *dest_addr, socklen_t addrlen,
|
|
|
|
const struct sockaddr_in6 *src_addr);
|
|
|
|
|
2014-02-25 10:07:47 +00:00
|
|
|
/* get_next_scheduled_send()
|
|
|
|
* return number of scheduled sendto
|
|
|
|
* set next_send to timestamp to send next packet */
|
2014-02-18 08:34:42 +00:00
|
|
|
int get_next_scheduled_send(struct timeval * next_send);
|
|
|
|
|
2014-02-25 10:07:47 +00:00
|
|
|
/* execute sendto() for needed packets */
|
2014-02-18 08:34:42 +00:00
|
|
|
int try_sendto(fd_set * writefds);
|
|
|
|
|
2014-02-25 10:07:47 +00:00
|
|
|
/* set writefds before select() */
|
2014-02-18 08:34:42 +00:00
|
|
|
int get_sendto_fds(fd_set * writefds, int * max_fd, const struct timeval * now);
|
|
|
|
|
2014-02-25 10:36:58 +00:00
|
|
|
/* empty the list */
|
|
|
|
void finalize_sendto(void);
|
|
|
|
|
2014-02-18 08:34:42 +00:00
|
|
|
#endif
|