Article View: borland.public.cppbuilder.internet.socket
Article #430Re: TClientSocket and Thread
From: Remy Lebeau (TeamB)
Date: Tue, 05 Feb 2008 22:27
Date: Tue, 05 Feb 2008 22:27
26 lines
2092 bytes
2092 bytes
"morbius" <dfdfdd@dkdkd> wrote in message news:47a8d4da$1@newsgroups.borland.com... > I have problem to pass the handle to the thread. If your thread is a TThread object, then you can simply add whatever parameters you want to its constructor. > Is it possible to create the Handle of the socket in the > main (to send commands) and use the same handle in > the thread for the gateway? Yes. However, you will have to serialize access to the socket, such as with a critical section, because you have multiple threads wanting to write data to the same socket at potentially the same time, so you have to handle such concurrency. If you had wanted to do all reading in one thread, and all writing in another thread, then there would be no concurrency problems. Why not simply create and use the socket inside the worker thread by itself? Then the main thread wouldn't have to access the socket at all. It could send requests to the worker thread to do the operations on the main thread's behalf instead. Gambit
Technical Details
Message-ID:
<47a8e28d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<47a780cb$1@newsgroups.borland.com> <47a8c3c4$1@newsgroups.borland.com> <47a8ce19$3@newsgroups.borland.com> <47a8d4da$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c9191e3622e2ffcf X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <47a780cb$1@newsgroups.borland.com> <47a8c3c4$1@newsgroups.borland.com> <47a8ce19$3@newsgroups.borland.com> <47a8d4da$1@newsgroups.borland.com> Subject: Re: TClientSocket and Thread Date: Tue, 5 Feb 2008 14:27:03 -0800 Lines: 28 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 207.178.157.90 Message-ID: <47a8e28d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1202250381 207.178.157.90 (5 Feb 2008 14:26:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail