socket.h 886 Bytes
Newer Older
1
2
3
4
5
6
#ifndef PRRT_SOCKET_H
#define PRRT_SOCKET_H

#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
7
#include "../defines.h"
8
#include "packet.h"
9
10
11
12
13

typedef struct {
    char* host_name;
    uint16_t port;
} prrt_receiver;
14
15
16
17

typedef struct {
    int fd_data;
    int fd_feedback;
18
19
20
21
22
23
    prrt_receiver receivers[PRRT_MAX_RECEIVER_COUNT];
    int receiver_len;
    uint16_t seqno_source;
    uint16_t seqno_repetition;
    uint16_t seqno_parity;
    uint16_t seqno_feedback;
24
25
} prrt_socket;

26
27
28
29
30

int prrt_create_socket(prrt_socket *sock_ptr, uint16_t port);
int prrt_close_socket(prrt_socket *sock_ptr);
int prrt_connect(prrt_socket *sock_ptr, char *host, uint16_t port);
int prrt_send(prrt_socket *sock_ptr, const void *data, size_t data_len);
31
prrt_packet *prrt_recv(prrt_socket *sock_ptr);
32
ssize_t prrt_recv_feedback(prrt_socket *sock_ptr, void *bufin, size_t length);
33
34

#endif // PRRT_SOCKET_H