socket.h 1.41 KB
Newer Older
1
2
3
#ifndef PRRT_SOCKET_H
#define PRRT_SOCKET_H

Andreas Schmidt's avatar
Andreas Schmidt committed
4
5
6
7
#include <src/defines.h>
#include <src/util/list.h>
#include <src/prrt/packet.h>
#include <src/prrt/stores/forward_packet_table.h>
8
9

typedef struct {
10
    const char* host_name;
11
    uint16_t port;
12
} PrrtReceiver;
13
14

typedef struct {
15
16
17
    int dataSocketFd;
    int feedbackSocketFd;
    pthread_t receiveFeedbackThread;
18

19
20
21
22
23
24
25
26
27
    pthread_t sendThread;
    pthread_mutex_t outQueueFilledMutex;
    pthread_cond_t outQueueFilledCv;
    List *outQueue;

    pthread_t receiveDataThread;
    pthread_mutex_t inQueueFilledMutex;
    pthread_cond_t inQueueFilledMutexCv;
    List *inQueue;
28

29
30
    PrrtForwardPacketTable* forwardPacketTable;

31
    PrrtReceiver receivers[PRRT_MAX_RECEIVER_COUNT];
32
33
34
35
36
37
    int receiverLength;
    uint16_t packetsCount;
    uint16_t sequenceNumberSource;
    uint16_t sequenceNumberRepetition;
    uint16_t sequenceNumberRedundancy;
    uint16_t sequenceNumberFeedback;
38
} PrrtSocket;
39

40

41
42
43
44
45
46
int PrrtSocket_create(PrrtSocket *sock_ptr, const uint16_t port, const uint8_t is_sender);
int PrrtSocket_close(const PrrtSocket *sock_ptr);
int PrrtSocket_connect(PrrtSocket *sock_ptr, const char *host, const uint16_t port);
int PrrtSocket_send(PrrtSocket *sock_ptr, const void *data, const size_t data_len);
uint32_t PrrtSocket_recv(const PrrtSocket *sock_ptr, void *buf_ptr);
PrrtPacket *PrrtSocket_recv_feedback(const PrrtSocket *sock_ptr, void *bufin, const size_t length);
47
48

#endif // PRRT_SOCKET_H