基于Netty+Zookeeper实现Dubbo
public class SocketTcpServer {
public static void main(String[] args) throws IOException {
// 創建Server Socket
ServerSocket serverSocket = new ServerSocket();
// 創建我們的 Socket 監聽連接地址和端口號
SocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 8080);
// 綁定我們的監聽地址
serverSocket.bind(address);
// 等待接受請求
System.out.println(“等待客戶端發送消息…”);
Socket accept = serverSocket.accept();
// 獲取OutputStream流
PrintWriter socketOut = new PrintWriter(accept.getOutputStream());
byte buf[] = new byte[1024];
if (accept.getInputStream().read(buf) > 0) {
System.out.println(“服務器端接受到客戶端消息:” + new String(buf));
}
// 服務器端響應消息
String sendStr = “每特教育平均就業薪資突破了3萬”;
socketOut.write(sendStr);
socketOut.flush();
}
總結
以上是生活随笔為你收集整理的基于Netty+Zookeeper实现Dubbo的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot系列四 Sprin
- 下一篇: MUI+H5手机上传照片 支持多图片上传