import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
public class SocketClient {
// 접속 시도하려는 IP, 포트번호 입력
public SocketClient(String host, int port) {
try {
Socket socket = new Socket(host, port);
OutputStream os = socket.getOutputStream();
os.write("Hello".getBytes());
InputStream is = socket.getInputStream();
byte[] b = new byte[10240];
int readCount = is.read(b);
System.out.println(new String(b, 0, readCount));
os.write("Hello".getBytes());
readCount = is.read(b);
} catch (Exception e) {
e.printStackTrace();
}
}
}
RECENT COMMENT