Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Full Duplex TIdTCPClient Architecture


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 27, 2018 2:44 PM Last Post By: Robert Kondner
Robert Kondner

Posts: 59
Registered: 11/15/01
Full Duplex TIdTCPClient Architecture  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2018 11:46 AM
Hi,
I have a Delphi 10.1 32 bit application on a Win 10 64 bit machine. The application collects strings from about 30 RS-232 to TCP devices that operate as TCP servers. I have one thread for each device each device has a unique IP address on our LAN. In each thread I have a TIdTCPClient where I use Readln to read strings. Works great, I can read strings from all the devices (bar code scanners).

If I wish to write data to the bar code scanners while I am waiting on the read of strings, what is the preferred architecture? Should I add another thread for the TIdTCPClient write functions? I could use Readln timeouts to create time slices for data writes, does that sound correct? My data rates are low and everything transfere is a string with a trailing #0d.

What do experienced Delphi Programmers do?

Thanks,
Bob K.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Full Duplex TIdTCPClient Architecture  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2018 1:25 PM   in response to: Robert Kondner in response to: Robert Kondner
Robert Kondner wrote:

If I wish to write data to the bar code scanners

What kind of data do you need to send to a barcode scanner? I've never
heard of that before.

while I am waiting on the read of strings, what is the preferred
architecture?

While one thread is reading from the socket, you can write to the same
socket in any other thread.

Should I add another thread for the TIdTCPClient write functions?

That is one way to do it.

I could use Readln timeouts to create time slices for data writes,
does that sound correct?

That is another option. That would be beneficial if you want the same
reading thread to also handle writes, such as having other threads
queue up writes using a TIdThreadSafeStringList that they push strings
into, and then the reading thread check the queue periodically for data
to send.

--
Remy Lebeau (TeamB)
Robert Kondner

Posts: 59
Registered: 11/15/01
Re: Full Duplex TIdTCPClient Architecture  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2018 2:44 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Robert Kondner wrote:

If I wish to write data to the bar code scanners

What kind of data do you need to send to a barcode scanner? I've never
heard of that before.

Remy Lebeau (TeamB)


Thanks for the feedback. I think I will use the time slices in the existing thread.

The data going back will actually go to conveyor width control logic. You are correct the scanners don't need data. As items come down a conveyor they have a certain width. The bar codes define the current object width. Before we allow the next conveyor to take the item its width must be set to match the next board. (PCBs are on the conveyor.) And we might need a small display to tell the operator how to set the manual conveyors.

Bob K.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02