#include <stdio.h>
#include <rtai_lxrt.h>
#include <rtai_netrpc.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <sys/io.h>
#define SERVER_IP "127.0.0.1"

int main()
{
    RT_TASK *server, *client;
    int priority = 0, stack_size = 4096, msg_size = 0;
    struct sockaddr_in addr;
    unsigned int server_node, server_port, msg = 0;
    client = rt_task_init(nam2num("client"), priority,
                              stack_size, msg_size);
    assert(client != 0);
    inet_aton(SERVER_IP, &addr.sin_addr);
    server_node = addr.sin_addr.s_addr;
    while((server_port = rt_request_port(server_node)) <= 0 &&
               server_port != -EINVAL);
    server = RT_get_adr(server_node, server_port, "servr");
    assert(server != 0);
    while(1) {
        RT_send(server_node, server_port, server, msg++);
        getchar();
    }
    rt_task_delete(client);
}
    
