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
   | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "unicast_socket_sendto.h"
 
int main(void) {
 
	puts("!!!test 7!!!"); /* prints !!!Hello World!!! */
	char *dest_ip = "127.0.0.1";
	char *message = "hello";
	int port = 7;
 
	printf("Tape a letter S or Q:");
	while (1){
 
		char c = getchar();
 
		if ((c=='s')||(c=='S'))
		{
			printf("Message sent: %s\n", message);
			unicast_socket_sendto(port, dest_ip, message);
			system("BREAK");
			return EXIT_SUCCESS;
		}
		else if ((c=='q')||(c=='Q'))
		{
			printf("QUIT\n");
			break;
		}
		else {
			printf("Invalid key, tape 'S' to send a message, 'Q' to exit");
				}
	}
 
} | 
Partager