2024-01-21 11:30:59 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-01-21 12:47:01 +01:00
|
|
|
#include "network.h"
|
2024-01-21 11:30:59 +01:00
|
|
|
|
2024-01-22 21:20:10 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int xPlaneSocket;
|
2024-01-21 11:30:59 +01:00
|
|
|
|
2024-01-22 21:20:10 +01:00
|
|
|
// check argument
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: %s <command>\n", argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2024-01-21 11:30:59 +01:00
|
|
|
|
2024-01-22 21:20:10 +01:00
|
|
|
// network
|
|
|
|
xPlaneSocket = createSocket(SRC_PORT);
|
|
|
|
if (xPlaneSocket < 0)
|
|
|
|
{
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2024-01-21 11:30:59 +01:00
|
|
|
|
2024-01-22 21:20:10 +01:00
|
|
|
// send payload
|
|
|
|
if (sendToXPlane(xPlaneSocket, DEST_SERVER, DEST_PORT, "CMND", argv[1], strlen(argv[1])) < 0)
|
|
|
|
{
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2024-01-21 11:30:59 +01:00
|
|
|
|
2024-01-22 21:20:10 +01:00
|
|
|
// bye bye (and no, I don't care about error anymore; I'll exit anyway?!)
|
|
|
|
closeSocket(xPlaneSocket);
|
|
|
|
exit(EXIT_SUCCESS);
|
2024-01-21 11:30:59 +01:00
|
|
|
}
|