Frage

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.

War es hilfreich?

Lösung

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.

Andere Tipps

I think you simply need

import java.net.ServerSocket

before your code.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top