作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我有一个 super 简单套接字服务器,它在localhost
的端口上接受连接:
: server-new ( port -- stream ) f swap <inet4> utf8 <server> accept drop ;
IN: scratchpad 1204 server-new
$ curl localhost:1204
_
server-new
在堆栈上保留一个
duplex-stream
。
T{ duplex-stream
{ in
T{ decoder
{ stream
T{ input-port
{ handle T{ fd { fd 36 } } }
{ buffer
T{ buffer
{ size 65536 }
{ ptr ALIEN: 1a44530 }
}
}
}
}
{ code utf8 }
}
}
{ out
T{ encoder
{ stream
T{ output-port
{ handle T{ fd { fd 36 } } }
{ buffer
T{ buffer
{ size 65536 }
{ ptr ALIEN: 1d42b30 }
}
}
}
}
{ code utf8 }
}
}
}
with-stream
或其他某种方式可以解决问题,但这只是消耗了流对象,而没有任何内容写入我的
curl
客户端。
最佳答案
它可能在某处缺少冲洗:
[ "hello from Factor" print flush ] with-stream
with-stream
将关闭流。如果要使其保持打开状态,请改为使用
with-stream*
。
关于sockets - 如何写入双工流?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36511260/
我是一名优秀的程序员,十分优秀!