Socket operation in a threaded application doesn't work as expected
Original Reporter info from Mantis: dphilippov
-
Reporter name: Denis Philippov
Original Reporter info from Mantis: dphilippov
- Reporter name: Denis Philippov
Description:
I'am trying to create a multithreaded http client of a http (audio|video)streaming server. My goal to mesure streams bitrates. I got a synapse library and put a simple http client into thread object. I clear THTTPSend.Document each time then the HR_ReadCount status event occured, record size of the block, time and calculate the bitrate.
Everything works well until I start 2 or more threads. I got 'Socket already connected' error on connect. To avoid this error I created new socket with THTTPSend.Sock.CreateSocket, THTTPSend.Sock.Disconnect. After this THTTPSend connects successfully, but reading from both connections stops with a 'connection time out' error.
Steps to reproduce:
Create a thread object and put a simple socket reading example into it. Create an app that starts a two or more such threads. See how it works.
Mantis conversion info:
- Mantis ID: 18226
- OS: Linux
- OS Build: Debian, Mandriva
- Platform: x86, x86_64
- Version: 2.4.2