diff --git a/net/p2pnet.h b/net/p2pnet.h index 1de67b5..a11e025 100644 --- a/net/p2pnet.h +++ b/net/p2pnet.h @@ -13,4 +13,6 @@ int socket_tcp4(void); int socket_stream_sctp4(void); + + int socket_udp4(void); #endif // P2PNET_H diff --git a/net/udp.c b/net/udp.c new file mode 100644 index 0000000..08dab8d --- /dev/null +++ b/net/udp.c @@ -0,0 +1,16 @@ +#include +#include +#include +#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; +}