Page 1 of 1

TServerSocket in thread

PostPosted: Tue Apr 05, 2016 3:42 am
by rajesh
Is that possible to use TServerSocket in thread I.e a class derived from TThread in c++builder6 . In Main Thread its events stop while doing some other processing

Re: TServerSocket in thread

PostPosted: Tue Apr 05, 2016 5:24 pm
by rlebeau
rajesh wrote:Is that possible to use TServerSocket in thread


Yes. But keep in mind that TServerSocket runs in non-blocking mode by default, and that requires the thread to have its own message loop to handle socket messages. If you don't want that, you will have to put TServerSocket into thread-blocking mode instead, and then use a TWinSockStream for all reads/writes on a connected socket.

rajesh wrote:In Main Thread its events stop while doing some other processing


As it should be, since the main message loop is getting blocked. Which is why you shouldn't be doing any long processing in the main thread to begin with.