Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

How can I use the tacopie server to send a lot of messages? #41

Open
sirilvk opened this issue Feb 14, 2018 · 2 comments
Open

How can I use the tacopie server to send a lot of messages? #41

sirilvk opened this issue Feb 14, 2018 · 2 comments

Comments

@sirilvk
Copy link

sirilvk commented Feb 14, 2018

Hi, I am using the tacopie server to handle a server internal to my application (a recovery server) and want to send a lot of messages. But the problem i see is immediately after all the async_writes the connection gets terminated even without checking if all the messages were successfully written onto the socket. Is there any way to confirm the same or at least wait till all the messages are flushed onto the socket.

Thanks,
Siril.

@sirilvk
Copy link
Author

sirilvk commented Feb 14, 2018

I have resolved the issue by directly sending out the message on the tcp_socket of the client. However would be nice to know if there is a way to force the async_write to flush all the data onto the socket.

Thanks,
Siril.

@yuangu
Copy link
Contributor

yuangu commented Jul 3, 2018

how big is your data?

ssize_t wr_size = ::send(m_fd, data.data(), __TACOPIE_LENGTH(size_to_write), 0);
change to

ssize_t wr_size = 0;
while(wr_size < size_to_write) {
ssize_t sendLen = ::send(m_fd, data.data() + wr_size, __TACOPIE_LENGTH(size_to_write - wr_size), 0);
if(sendLen <= 0)
{
break;
}
wr_size += sendLen;
}

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

No branches or pull requests

2 participants