import java.net.Socket import java.io.*

%# connect to server

I want to socket network in Matlab.

it worked well until yesterday but suddenly it doesn't work with error message..

while true

    fprintf('Server start...');


    sockets.client_socket = ServerSocket(6678);
    sockets.client_output = sockets.client_socket.accept;
    output_socket = sockets.client_output;

    ..............

end

error message =>

[ Undefined function or method 'ServerSocket' for input arguments of type 'double'. Error in ==> Con_sock at 19 sockets.client_socket = ServerSocket(6678);]

How can i do? I tried to change 6678 data type to int8(), uint8() also.

有帮助吗?

解决方案

As far as I know, there is no ServerSocket function in Matlab so you are probably referring to an external class.

If you want to operate with sockets in Matlab, the proper way to do it is by using the tcpip funcion:

socket=tcpip('0.0.0.0', 30000, 'NetworkRole', 'server')

From there you can listen and receive the data.

其他提示

I think you simply need

import java.net.ServerSocket

before your code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top