aboutsummaryrefslogtreecommitdiff
path: root/src/Socket.cpp
blob: 1b39c19b8ec33a7da241c4e91728ff70deae359c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "../include/sibs/Socket.hpp"
#include <udt/udt.h>

namespace sibs
{
    Socket::Socket() : 
        eid(-1),
        udtSocket(-1)
    {

    }

    Socket::Socket(int _udtSocket) : 
        eid(-1),
        udtSocket(_udtSocket)
    {

    }

    Socket::Socket(int _eid, int _udtSocket) : 
        eid(_eid),
        udtSocket(_udtSocket)
    {

    }

    Socket::Socket(Socket &&other)
    {
        eid = other.eid;
        udtSocket = other.udtSocket;
        other.eid = -1;
        other.udtSocket = -1;
    }

    Socket::~Socket()
    {
        if(udtSocket != -1)
        {
            if(eid != -1)
                UDT::epoll_remove_usock(eid, udtSocket);
            UDT::close(udtSocket);
        }
    }
}