Commit d44b6c69 authored by rna's avatar rna

Merge branch 'develop' into feature/congestionControl

parents 7650f453 eaf833c7
Pipeline #2535 passed with stages
in 1 minute and 25 seconds
......@@ -223,6 +223,12 @@ int PrrtSocket_send(PrrtSocket *s, const uint8_t *data, const size_t data_len) {
PERROR("Data to be sent (%ld bytes) is too long, as MTU is %d.\n", data_len, s->maximum_payload_size);
return -1;
}
if(s->receiver == NULL) {
PERROR("PrrtSocket_connect() must be called before PrrtSocket_send().\n");
return -1;
}
XlapTimestampPlaceholder tsph;
XlapTimestampPlaceholderInitialize(&tsph);
XlapTimeStampClock(&tsph, ts_any_packet, 0, PrrtSendStart);
......
......@@ -135,6 +135,7 @@ class PrrtCodingConfiguration:
cdef class PrrtSocket:
cdef cprrt.PrrtSocket* _c_socket
_epoch = datetime.datetime.utcfromtimestamp(0)
_connected = False
def __cinit__(self, address, maximum_payload_size = 1400, target_delay = 1, thread_pinning = False):
host, port = address
......@@ -202,11 +203,14 @@ cdef class PrrtSocket:
host, port = address
cdef bytes encodedHost = host.encode("utf-8")
cprrt.PrrtSocket_connect(self._c_socket, encodedHost, port)
self._connected = True
def send(self, data):
if not self._connected:
raise Exception("PrrtSocket must be connected first, before data can be sent.")
maximum_payload_size = cprrt.PrrtSocket_get_sock_opt(self._c_socket, "maximum_payload_size")
data_len = len(data)
if len(data) < maximum_payload_size:
if len(data) <= maximum_payload_size:
cprrt.PrrtSocket_send(self._c_socket, data, data_len)
else:
raise PayloadTooBigException("Sending packet of {} bytes on a socket with maximum payload size of {} bytes failed.".format(data_len, maximum_payload_size))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment