private PrintStream proxiedPrintStream() throws ProxyStreamException {
Proclet procletContext = Proclet.currentProcletContext();
int pid = (procletContext == null) ? ProcletIOContext.GLOBAL_STREAM_ID : procletContext.getPid();
PrintStream ps = getProxiedStream(pid);
if (ps == null) {
throw new ProxyStreamException(
"Proclet stream not set (fd = " + fd + ")");
} else if (ps instanceof ProcletProxyStream) {
throw new ProxyStreamException(
"Proclet stream points to another proclet stream (fd = " + fd + ")");
}
return ps;
}