Commit 0ac2c449 authored by Andreas Schmidt's avatar Andreas Schmidt

Start send_loop on connect.

parent ffa809aa
......@@ -174,20 +174,11 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
check(setsockopt(s->socketFd, SOL_SOCKET, SO_TIMESTAMPING, &enabled2, sizeof(enabled2)) >= 0, "Could not set SO_TIMESTAMPING");
}
s->sendDataThreadAttr = calloc(1, sizeof(pthread_attr_t));
pthread_attr_init(s->sendDataThreadAttr);
s->receiveDataThreadAttr = calloc(1, sizeof(pthread_attr_t));
pthread_attr_init(s->receiveDataThreadAttr);
if(s->isThreadPinning) {
pin_thread_to_core(s->receiveDataThreadAttr, 2);
pin_thread_to_core(s->sendDataThreadAttr, 1);
}
check(pthread_create(&s->sendDataThread, s->sendDataThreadAttr, send_data_loop,
(void *) s) == EXIT_SUCCESS, "Cannot create send thread.");
pthread_attr_init(s->receiveDataThreadAttr);
check(pthread_create(&s->receiveDataThread, s->receiveDataThreadAttr, receive_data_loop,
(void *) s) == EXIT_SUCCESS, "Cannot create data receiving thread.");
......@@ -199,12 +190,21 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
return false;
}
int PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port) {
if(s->receiver != NULL) {
PrrtReceiver_destroy(s->receiver);
}
bool PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port) {
check(s->receiver == NULL, "PrrtSocket_connect can only be called once.");
s->receiver = PrrtReceiver_create(host, port);
return 0;
s->sendDataThreadAttr = calloc(1, sizeof(pthread_attr_t));
if(s->isThreadPinning) {
pin_thread_to_core(s->sendDataThreadAttr, 1);
}
pthread_attr_init(s->sendDataThreadAttr);
check(pthread_create(&s->sendDataThread, s->sendDataThreadAttr, send_data_loop,
(void *) s) == EXIT_SUCCESS, "Cannot create send thread.");
return true;
error:
PERROR("PrrtSocket_connect failed.%s","");
return false;
}
int PrrtSocket_send(PrrtSocket *s, const uint8_t *data, const size_t data_len) {
......
......@@ -104,7 +104,7 @@ int PrrtSocket_interrupt(PrrtSocket *s);
int PrrtSocket_close(PrrtSocket *s);
int PrrtSocket_connect(PrrtSocket *s, const char *host, uint16_t port);
bool PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port);
int PrrtSocket_send(PrrtSocket *s, const uint8_t *data, size_t data_len);
......
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