no matter what i do i get this error: (line 17) fopen(server);

2 次查看(过去 30 天)
this is the part of my code i get the error
% Set up TCP/IP server for receiving data
server = tcpip('0.0.0.0', 12345, 'NetworkRole', 'server');
server.InputBufferSize = N;
server.Timeout = 30;
fopen(server);
% Wait for client connection
disp('Waiting for client connection...');
while server.BytesAvailable == 0
pause(0.1);
end
disp('Client connected.');
% Set up TCP/IP client for sending data
client = tcpip('localhost', 12345, 'NetworkRole', 'client');
client.OutputBufferSize = N;
fopen(client);
% Transmit and receive data between client and server
T_near_edge = transmit_and_receive_data(T_sensor, client, server, N);
% Close TCP/IP server and client
fclose(server);
fclose(client);
delete(server);
delete(client);
  1 个评论
HimeshNayak
HimeshNayak 2023-3-16
“fopen” tells it to wait until a connection is requested. After the “fopen” there will be a connection unless the attempt fails.
Could you share the exact error you are receiving?

请先登录,再进行评论。

回答(1 个)

Sai Sumanth Korthiwada
Hi Kyriakos,
I understand that you are facing an issue with 'fopen()'. As per the shared code, you are using 'tcpip()' and 'fopen()' methods.
Use 'tcpclient()' to create a TCP/IP client that connects to a server or hardware and perform read and write operations.
'tcpip()' will be removed in a future release. Please use tcpclient or tcpserver instead. For more information on updating your code, see Compatibility Considerations.
And create 'tcpip' client using: Create TCP/IP Client and Configure Settings
Also, 'fopen(obj)' function will be removed in a future release. Use serialport object functions instead. For more information on updating your code, see Compatibility Considerations.
Hope this helps!

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by