From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If I put a TCP Read function before a TCP Write function (both in a while loop of the server) and I do the same thing in the client, the performance slows?

I am programming an application client-server, both sending and receiving data.
0 Kudos
Message 1 of 3
(2,563 Views)
This is probably because the Read in your client is waiting for data that won't exist, and times out. Try changing the order so that they don't match (i.e. Read then Write in your Client, and Write then Read in your server.) Also, make sure you have the appropriate mode, i.e. Immediate, or CRLF or whatever is appropriate.

I recently created a TCP/IP Eavesdropper to stand between a Client and Server, and had no problems with performance once I got the right mode (I wasn't sure what the Client/Server were using, so it took a few tries to get it right.)
Message 2 of 3
(2,563 Views)
The best format would be to decouple reading and writing into separate
threads. In the read loop, just have it check for the number of bytes
available, read those bytes add them to a shift register string buffer
or better yet a queue and then loop around to do it again.

If you use a queue then you can create a while loop to process
commands from the queue. If you don't use a queue then you will need
to process commands in the read loop.

The writing can then be done only as required in a separate while loop
by sending a signal (notifier, occurrence, etc.) from the command loop
to the write loop.

Alternatively the command processing loop could dynamically spawn VI's
to process commands and perform the TCP writes and close the socket
connections if requ
ired.

Douglas De Clue
ddeclue@bellsouth.net





boxer wrote in message news:<506500000008000000A1500000-1023576873000@exchange.ni.com>...
> If I put a TCP Read function before a TCP Write function (both in a
> while loop of the server) and I do the same thing in the client, the
> performance slows?
>
> I am programming an application client-server, both sending and
> receiving data.
Message 3 of 3
(2,563 Views)