Problem reading from server socket
I've implemented a simple TCP server using the ServerSocket class (code below) to communicate with a client. They should just exchange strings. The client comes off-the-shelf with a sensor I need to use and, although I don't have access to its source code, I know all the commands I can R/W from it. The server starts listening and as soon as the client connects to it, the client is supposed to send a string with 3 initialization commands of the type "command 1\r\n command 2\r\n command 3\r\n". \r\n denotes the end of a command.
The problem is, my server can't seem to read this initial string and then the client has a timeout because the server doesn't reply appropriately. I know the initial string packet is being sent because I can see it with a network sniffer (Wireshark). Does anyone have an idea why my server hasn't been able to read it?
port = 16544;
server = ;
s = ;
command = ;
% Creates the server socket if port is available
fprintf(1, ['Waiting for the client to connect...\n']);
server = ServerSocket(port);
% Listens on the specified port
server.setSoTimeout(0); % Wait forever
s = server.accept; % Start listening
fprintf(1, 'Server connected\n');
% Socket options
s.setKeepAlive(true) % Heartbeat
s.setTcpNoDelay(true) % Nable's algorithm off
% R/W streams
in = BufferedReader(InputStreamReader(s.getInputStream));
out = DataOutputStream(s.getOutputStream);
% read data
command = in.readLine;
command = char(command);
% write data
CRLF = [char(13),char(10)];
case 'command 1'
case 'command 2'
% clean up