I would like to add a method to send a String of message to client, it was hard to find a good example on the web. Does it use write
for sending message to port 8090, do I need to add flush as well?
try {
InetAddress addr = InetAddress.getByName("127.0.0.1");
int port = 8090;
Socket socket = new Socket(addr, port);
} catch (UnknownHostException e) {
} catch (IOException e) {
}
查看“ 自定义网络”教程中的一些可用示例。
You can get the output stream object from the method socket.getOutputStream(). Once you get the output stream you can write using the stream.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.