This shows you the differences between two versions of the page.
| — | sdk:scripts:udpclient [2015/05/05 15:04] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SDK Script udpclient.are ====== | ||
| + | <code c udpclient.are> | ||
| + | /* DESC: This script sends a message to a remote UDP server. | ||
| + | * Copyright (C) 2012 NetModule AG, Switzerland | ||
| + | */ | ||
| + | |||
| + | void usage() | ||
| + | { | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | if (argc < 4) { | ||
| + | usage(); | ||
| + | } | ||
| + | |||
| + | SERVER = argv[1]; | ||
| + | PORT = (int) argv[2]; | ||
| + | MSG = ""; | ||
| + | |||
| + | for (i = 3; i < argc; i++) { | ||
| + | MSG = strcat(MSG, " ", argv[i]); | ||
| + | } | ||
| + | |||
| + | sock = socket(AF_INET, | ||
| + | if (sock < 0) { | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | sent = sendto(sock, | ||
| + | |||
| + | if (sent == strlen(MSG)) { | ||
| + | printf(" | ||
| + | } else { | ||
| + | printf(" | ||
| + | } | ||
| + | |||
| + | exit(0); | ||
| + | |||
| + | </ | ||