import java.net.*; import java.io.*; class Server { private ServerSocket server; private Socket client; private OutputStreamWriter writer; private InputStreamReader reader; public Server() { server= null; client = null; reader = null; writer = null; } public void printLocalInfo() { if(server == null){return;} try{ System.out.println("port"+ server.getLocalPort()); System.out.println("add "+ InetAddress.getLocalHost()); }catch(Exception e) { } } public void start() { try{ server = new ServerSocket(5555); client = server.accept(); writer = new OutputStreamWriter(client.getOutputStream()); }catch(Exception e) {System.out.println("Don't Open 2222");} } public void send(String message) { if(writer == null){return;} try{ writer.write(message,0,message.length()); writer.flush(); }catch(Exception e) { System.out.println("Dont's send mesage"); } } public void close() { if(client == null){return;} try{ client.close(); }catch(Exception e) { System.out.println("Don't close"); } } public static void main( String args[]) { Server s = new Server(); s.start(); s.send("Mirage_tech"); s.close(); } }