首先查看 Socket.getOutputStream 方法可以知道此 outputStream 是由 impl 获取的
public OutputStream getOutputStream() throws IOException {
...
OutputStream os = null;
try {
os = AccessController.doPrivileged(
new PrivilegedExceptionAction<OutputStream>() {
public OutputStream run() throws IOException {
return impl.getOutputStream();
}
});
} catch (java.security.PrivilegedActionException e) {
throw (IOException) e.getException();
}
return os;
}
impl 的实现就得看 ServerSocket 是拿到的什么样的 Socket 了,看 Socket.accept() 方法
public Socket accept() throws IOException {
if (isClosed())
throw new SocketException("Socket is closed");
if (!isBound())
throw new SocketException