Implemented initial UDP socket.

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-11-10 19:43:31 -03:00
parent 648982793c
commit 2b55ebfeb4
2 changed files with 18 additions and 0 deletions

View file

@ -13,4 +13,6 @@
int socket_tcp4(void);
int socket_stream_sctp4(void);
int socket_udp4(void);
#endif // P2PNET_H

16
net/udp.c Normal file
View file

@ -0,0 +1,16 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "p2pnet.h"
/* Create a UDP socket.
*/
int socket_udp4(void)
{
int s;
s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1) return -1;
return s;
}