add set_non_blocking() to upnputils.c/h
This commit is contained in:
parent
0695b341a6
commit
f34ab24d99
|
@ -1,13 +1,15 @@
|
||||||
/* $Id: upnputils.c,v 1.3 2011/05/20 09:42:23 nanard Exp $ */
|
/* $Id: upnputils.c,v 1.4 2012/02/06 16:21:24 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2011 Thomas Bernard
|
* (c) 2006-2012 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -65,4 +67,14 @@ sockaddr_to_string(const struct sockaddr * addr, char * str, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
set_non_blocking(int fd)
|
||||||
|
{
|
||||||
|
int flags = fcntl(fd, F_GETFL);
|
||||||
|
if(flags < 0)
|
||||||
|
return 0;
|
||||||
|
if(fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $Id: upnputils.h,v 1.1 2011/05/15 08:58:41 nanard Exp $ */
|
/* $Id: upnputils.h,v 1.2 2012/02/06 16:21:24 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2011 Thomas Bernard
|
* (c) 2011-2012 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
|
@ -16,5 +16,12 @@
|
||||||
int
|
int
|
||||||
sockaddr_to_string(const struct sockaddr * addr, char * str, size_t size);
|
sockaddr_to_string(const struct sockaddr * addr, char * str, size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the file description as non blocking
|
||||||
|
* return 0 in case of failure, 1 in case of success
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
set_non_blocking(int fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue