31 lines
774 B
C
Executable File
31 lines
774 B
C
Executable File
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <netinet/in.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <arpa/inet.h>
|
|
#include <netdb.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct sockaddr_in adr;
|
|
int s, bytesSend;
|
|
char message = 0x0a;
|
|
|
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
|
adr.sin_family = AF_INET;
|
|
adr.sin_port = htons(40);
|
|
adr.sin_addr.s_addr = inet_addr("150.254.76.1");
|
|
|
|
bytesSend = (int) sendto(s,&message, 1, 0, (struct sockaddr*) &adr, sizeof(adr));
|
|
if (bytesSend != 1) {
|
|
printf("SOME ERROR.");
|
|
} else {
|
|
printf("UDP PACKET WAS SEND.");
|
|
}
|
|
close(s);
|
|
return 0;
|
|
} |