I have two threads, each with a buffer with some data. I have a function 开发者_如何学运维that writes to a TCP socket. (I use ffmpeg for it.) How will the data packets arrive at the server — in some crazy mixed up way, or in some other order, or will the OS (Windows, in my case) make one thread wait until the other has finished?
That depends entirely upon which implementation of "sockets" you are using. If your implementation is synchronized, you'll get the first thread's data, followed by the second thread's data (The second thread will block while the first sends). If your implementation is not synchronized, you'll get gibberish.
mmm, well, you have to synchronize them, to avoid unexpected results.
精彩评论