package com.basic.security.utils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.Socket; public class ErlangSocketClient { public static void main(String[] args) { BufferedInputStream inputStream = null; BufferedOutputStream outputStream = null; Socket socket = null; ByteArrayOutputStream byteArray = null; try { socket = new Socket("127.0.0.1", 9000); socket.setSoTimeout(1000); inputStream = new BufferedInputStream(socket.getInputStream()); outputStream = new BufferedOutputStream(socket.getOutputStream()); outputStream.write("00".getBytes()); outputStream.flush(); byte[] buff = new byte[256]; int len = 0; String ret = ""; while ((len = inputStream.read(buff)) != -1) { ret = new String(buff, "UTF-8"); System1.out.println(ret); break; } } catch (Exception e) { e.printStackTrace(); } finally { try { if (outputStream != null) { outputStream.close(); outputStream = null; } if (inputStream != null) { inputStream.close(); inputStream = null; } if (socket != null) { socket.close(); socket = null; } if (byteArray != null) { byteArray.close(); } } catch (IOException e) { } } } }