#include <arpa/inet.h>  // network
#include <stdio.h>      // perror
#include <sys/socket.h> // network
#include <unistd.h>     // exit
#include <string.h>     // memset

#define TARGET_IP   "192.168.1.50"
#define TARGET_PORT 3000

int main(void) {
	struct sockaddr_in si_output; // my socket
	int s; // socket

	if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { perror("socket"); _exit(1);}
	memset((char*)&si_output, sizeof(si_output), 0);
	si_output.sin_family  = AF_INET;
	si_output.sin_port    = htons(TARGET_PORT);
	if (inet_aton(TARGET_IP, &si_output.sin_addr) == 0) { perror("inet_aton() failed"); _exit(1); }

	char buf[50] = "Test UDP Packet";
	if (sendto(s, buf, sizeof(buf), 0, (struct sockaddr *)&si_output, sizeof(si_output)) == -1) {
		perror("Error: sendto");
		_exit(1);
	}
	
	close(s);
	return 0;
}
