Blame view

bin/test.c 850 Bytes
32c9271a   skhinach   modif
1
2
  #include <stdlib.h>
  #include <stdio.h>
fff6f037   skhinach   modifs
3
  #include <unistd.h>
32c9271a   skhinach   modif
4
5
  #include <getopt.h>
  #include <string.h>
fff6f037   skhinach   modifs
6
  #include <signal.h>
32c9271a   skhinach   modif
7
8
9
  #include "libnet.h"
  
  
fff6f037   skhinach   modifs
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  int sock_fd;
  
  struct sigaction action;
  
  void handler(int sig)
  {
  	if(sig==SIGINT)
  	{
  		printf("\nINTERRUPTION SOCKET : %d\n\n", sock_fd);
  		close(sock_fd);
  		exit(1);
  	}
  }
  
  
32c9271a   skhinach   modif
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  void argPortParsing(int argc, char* argv[], char* port)
  {
  	struct option port_arg={"port", 1, NULL, 'p'};
  	char opt;
  	int longindex;
  
  	while( (opt=getopt_long(argc, argv, "p:", &port_arg, &longindex)) !='p' && opt!=-1) {}
  
  	if(opt=='p') 
  	{
  		strcpy(port, optarg);
  		printf("%s\n", optarg);
  	}
  	else
  	{
  		printf("La syntaxe doit ĂȘtre de la forme %s -p <port> ou %s --port <port>\n\n", argv[0], argv[0]);
  	}
  }
  
  
  int main(int argc, char* argv[])
  {
8a59b888   pifou   test
47
48
    char msg[2] = {0x40,0x01};
    sendUDPUnicast("172.26.145.205",msg, 2020);
32c9271a   skhinach   modif
49
50
  	return 0;
  }