Skip to main content
9 events
when toggle format what by license comment
Jul 6 at 10:08 vote accept John
Jun 27 at 3:06 comment added John @GuntramBlohm If you have a UDP socket, and have two threads send smallish packets over it, you're guaranteed that packets from those threads stay intact. What about long message via UDP? It's hard to say how many bytes could be smallish. So even for the UDP, mutex is still needed if it would be sent by multiple threads. Am I right?
Jun 26 at 16:14 comment added Guntram Blohm @John: re your 2) If you have a UDP socket, and have two threads send smallish packets over it, you're guaranteed that packets from those threads stay intact. You won't get partial packets which are resumed after a packet from another thread. If it's a TCP socket, and you're writing large chunks, especially when buffers run full, there's a good chance your chunks will be split. When exactly depends on many factors, so you might need a mutex, might want a mutex just to be certain, or know you don't need a mutex.
Jun 26 at 12:56 comment added John TcpServer::send is used to send message every 30ms. Losing some messages is acceptable.
Jun 26 at 7:07 comment added John Thanke you. 1. You said it's perfectly ok to read and write a socket from two threads at the same time. However, m_socket_fd is used by threads which both read and write it(i.e. TcpServer::send() may be still called while the value of m_socket_fd is modified after accept() sucessfully returns and TcpServer::close may be called by either of the two threads). 2. You said read up about which write operations of which size on which kind of socket are or aren't atomic. Sorry I can't get it.Could you please explain that for me? 3. m_ prefix is short for member.
Jun 25 at 23:11 comment added Remember Monica sidenote: : ip(ip) actually works as expected(?), no need to name either any differently.
Jun 25 at 18:31 history edited Guntram Blohm CC BY-SA 4.0
added 334 characters in body
Jun 25 at 18:23 history edited Guntram Blohm CC BY-SA 4.0
added 440 characters in body
Jun 25 at 18:17 history answered Guntram Blohm CC BY-SA 4.0