🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
7 messages
7 total messages Started by morbius Mon, 04 Feb 2008 21:17
TClientSocket and Thread
#425
Author: morbius
Date: Mon, 04 Feb 2008 21:17
6 lines
1142 bytes
Hello

I want to make a client with TClientSocket and use a Thread in blocking 
mode. (gateway to com port)
I search a example because I don't know how to write  the thread and what 
are the arguments to pass to the thread? 
Re: TClientSocket and Thread
#426
Author: Remy Lebeau (TeamB)
Date: Mon, 04 Feb 2008 21:23
11 lines
1331 bytes
"morbius" <dfdfdd@dkdkd> wrote in message 
news:47a780cb$1@newsgroups.borland.com...

> I search a example because I don't know how to write  the thread

There have been plenty of examples posted showing how to use TClientSocket 
in a thread.  What search criteria are you using?


Gambit 
Re: TClientSocket and Thread
#427
Author: morbius
Date: Tue, 05 Feb 2008 20:15
7 lines
1163 bytes
Hello Gambit

I need my thread works like a gateway :
I send some commands to the server and then the thread reads et sends on a
virtual com port and  sends to server via the socket   "

thank you
Re: TClientSocket and Thread
#428
Author: Remy Lebeau (TeamB)
Date: Tue, 05 Feb 2008 20:31
13 lines
1360 bytes
"morbius" <dfdfdd@dkdkd> wrote in message 
news:47a8c3c4$1@newsgroups.borland.com...

> I need my thread works like a gateway :
> I send some commands to the server and then the thread
> reads et sends on a virtual com port and  sends to server
> via the socket   "

So what is the actual problem you are having with it?


Gambit 
Re: TClientSocket and Thread
#429
Author: morbius
Date: Tue, 05 Feb 2008 21:27
3 lines
1127 bytes
1) I have problem to pass the handle to the thread.
2) 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?
Re: TClientSocket and Thread
#430
Author: Remy Lebeau (TeamB)
Date: Tue, 05 Feb 2008 22:27
26 lines
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 
Re: TClientSocket and Thread
#431
Author: morbius
Date: Tue, 05 Feb 2008 22:42
7 lines
1274 bytes
Ok

I follow you, I use the only main thread to communicate to the server.
I make a function in the main to read and write on the socket and on the com 
port.

thank you, Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads