Initial commit of files

This commit is contained in:
2021-01-22 10:16:20 -05:00
parent 32d165ec8f
commit ed92211680
534 changed files with 68563 additions and 19 deletions

View File

@ -0,0 +1,40 @@
//
// Neal Probert
//
#include "netlib.h"
int udp_broadcast( const char *host, const char *service, struct sockaddr_storage *sa, socklen_t *len )
{
/* socket stuff */
int sock, family; /* tcp socket */
if ( !host )
host = "255.255.255.255";
// host
family = ip_host2addr( host, service, sa, len );
if ( family != AF_INET )
{
log_error(host);
return -1;
}
/* plug me into a socket */
if ( (sock = socket( family, SOCK_DGRAM, 0)) < 0 )
{
log_error("dgram_socket");
return -1;
}
// ipv4 uses classic broadcast
u_int i = 1;
if ( setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &i, sizeof(i)) != 0 )
{
log_error("so_broadcast");
return -1;
}
return sock;
}