import java.io.*;
import java.net.*;
import java.util.*;
PORT = 10001;
messages = ...
['******************************';...
 '*** Welcome to Java World! ***';...
 '******************************'];
try 
aServerSocket = ServerSocket(PORT);
fprintf('Waiting for connection port[%d]\n',PORT);
while (1) 
  aSocket = accept(aServerSocket);
  remoteName = getHostName(getInetAddress(aSocket));
  logMessage = [char(remoteName),' connected at ' , datestr(now)];
  disp(logMessage);
  aWriter = BufferedWriter(OutputStreamWriter(getOutputStream(aSocket)));
  for i = 1:3
    write(aWriter,messages(i,:), 0,length(messages(i,:)));
    newLine(aWriter);
  end
  close(aWriter);
end
catch
disp('jkjkl');
close(aSocket);
close(aServerSocket);
end