Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libutp in a multi-thread application #135

Open
gregoiregentil opened this issue Oct 17, 2022 · 0 comments
Open

libutp in a multi-thread application #135

gregoiregentil opened this issue Oct 17, 2022 · 0 comments

Comments

@gregoiregentil
Copy link

Hello,

Thank you for your efforts on this library. It's a lot of work.

This is not really a bug report, it could be seems as a feature request, or more likely, it's a call for advice.

I'm trying to use libutp in a multi-thread applications with multiple UTP communication over a single UDP socket. I have read the warning in the paragraph Interface of the readme.

I have one instance of:

`
socketUDP = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
bind(socketUDP, (struct sockaddr*)(&si_me), sizeof(si_me));
ctx = utp_init(2);
utp_set_callback(ctx, ...);

struct pollfd pollfds[1];
pollfds[0].fd = socketUDP;
pollfds[0].events = POLLIN;
while (1) {
poll(pollfds, 1, -1);
if (pollfds[0].revents & POLLIN) {
recvfrom(socketUDP,
utp_process_udp(ctx, socket_data, len, (struct sockaddr *)&src_addr, addrlen);
}
}
`

I have multiple instances from different threads:

utp_socket *sock = utp_create_socket(ctx); utp_connect(sock, (struct sockaddr *)&sin, sizeof(sin)); utp_write(sock, ...);

I have in place a system NOT to mix the different 'write' buffers.

Nevertheless, the library doesn't like it and I get crashes especially when utp_write happen at the same time.

Is there an example or a paper suggesting how to use libutp in a multi-thread app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant