Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

I think you simply need

import java.net.ServerSocket

before your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top