use net_socket so that in adheres the global ipv4/ipv6 setting
#include "ext-lpd.h"
-// Set a socket non-blocking; defined in src/net.c
-int net_set_nonblocking( int fd );
-
enum {
// Packets per minute to be handled
PACKET_LIMIT_MAX = 20,
@@ -111,11 +108,7 @@ int create_send_socket( int af, const char ifname[] ) {
const int opt_off = 0;
int sock;
- if( (sock = socket( af, SOCK_DGRAM, IPPROTO_IP ) ) < 0 ) {
- goto fail;
- }
-
- if( net_set_nonblocking( sock ) != 0 ) {
+ if( (sock = net_socket( "LPD", ifname, IPPROTO_IP, af ) ) < 0 ) {
goto fail;
}
@@ -158,17 +151,11 @@ fail:
}
int create_receive_socket( const IP *addr, const char ifname[] ) {
- const int opt_on = 1;
const int opt_off = 0;
const int af = addr->ss_family;
+ int sock;
- int sock = socket( addr->ss_family, SOCK_DGRAM, IPPROTO_IP );
-
- if( net_set_nonblocking( sock ) != 0 ) {
- goto fail;
- }
-
- if( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, (void const*) &opt_on, sizeof(opt_on) ) != 0 ) {
+ if( (sock = net_socket( "LPD", ifname, IPPROTO_IP, af ) ) < 0 ) {
goto fail;
}
