Effacer les filtres
Effacer les filtres

Tcpclient function very slow.

17 vues (au cours des 30 derniers jours)
NEERAJ GILL
NEERAJ GILL le 11 Jan 2023
Modifié(e) : Walter Roberson le 30 Juin 2024 à 2:37
Here is the example tcpclient I use. I it takes 2.3 seconds to send the command. Can anyone let me know what I am doing wrong.
commandstr = 'echo'
tic
t = tcpclient('localhost',Portnumber);
t.ByteOrder = "big-endian";
% configureTerminator(t,"CR/LF")
write(t ,length(commandstr),'uint32');
write(t,commandstr);
BytesToRead = read(t,1,'uint32');
B = read(t,BytesToRead,'string');
command_sent = strip(B);
clear t
toc
Elapsed time is 2.353485 seconds.
  1 commentaire
Brent
Brent le 29 Juin 2024 à 19:26
Matlab keeps pinging me to switch from tcpip (which it says will be deprecated someday) to tcpclient. When I do the the communications take literally 4X as long...

Connectez-vous pour commenter.

Réponses (1)

Animesh
Animesh le 8 Mar 2023
Hello,
There are several possible reasons why the tcpclient function may be slow:
  • Network issues: Slow network speed or high network latency can cause delays in establishing a connection or transmitting data between the client and server. You may want to check your network settings, firewall, and ensure that both the client and server are connected to the same network.
  • Server issues: The server may be experiencing high traffic or processing load, which could lead to slow response times. You can try running the client on a different network or computer to see if the issue persists.
  • Client-side issues: The client may have insufficient processing power, memory or disk space, which could cause delays in reading or writing data. You can try closing other programs or freeing up resources to see if that improves the performance.
  • Code issues: There may be issues with the code that is using the tcpclient function, such as inefficient algorithms, blocking calls or incorrect settings. You can try optimizing the code, using asynchronous calls, or changing the buffer size to see if that improves the performance.
  • Server-side settings: The server may be configured to limit the number of concurrent connections, restrict the bandwidth, or impose other limitations that could impact the client's performance. You can try adjusting the server settings or contacting the server administrator to see if there are any issues.
Overall, troubleshooting performance issues with the tcpclient function can be complex and may require a systematic approach that involves checking the network settings, server status, client resources, code efficiency, and server settings.
  1 commentaire
Rui
Rui le 7 Nov 2023
This answer was 100% completely generated with ChatGPT

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by