-
Notifications
You must be signed in to change notification settings - Fork 29
/
udp.h
39 lines (30 loc) · 963 Bytes
/
udp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* udp.h
* By Ron
* Created August, 2008
*
* (See LICENSE.txt)
*
* Platform-independent module for creating/sending TCP sockets for IPv4 UDP packets.
*/
#ifndef __UDP_H__
#define __UDP_H__
/*#ifdef WIN32
#include <winsock2.h>
#else
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#endif*/
#include "types.h"
/* Must be called before any other functions. This is actually defined in tcp.c. */
void winsock_initialize();
/* Create a UDP socket on the given port. */
int udp_create_socket(uint16_t port, char *local_address);
/* Read from the new socket, filling in the 'from' field if given. Not currently being used. */
/*size_t udp_read(int s, void *buffer, size_t buffer_length, struct sockaddr_in *from);*/
/* Send data to the given address on the given port. */
void udp_send(int sock, char *address, uint16_t port, void *data, size_t length);
/* Close the UDP socket. */
int udp_close(int s);
#endif