You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
robomaster-sdk/src/connection.h

29 lines
721 B
C

#pragma once
#include "message.h"
#include "client.h"
#include <stddef.h>
#include <netinet/in.h>
// The greated file descriptor is needed for polling the sockets.
// It needs to be global for the whole process.
// TODO: Should probably just move the polling function to connection.c
extern int max_fd;
struct Connection {
int sockfd;
socklen_t addrlen;
struct sockaddr_in remote_addr;
};
struct Connection*
connection_new(unsigned int source_port, const char* source_ip, unsigned int dest_port, const char* dest_ip);
void
req_finalize(struct Client* client, uint8_t cmdset, uint8_t cmdid, size_t length, union Request* req);
void
req_send(struct Connection* conn, union Request* req, size_t length);