草庐IT

c# - 系统.IO.Exception : Pipe is broken

我有两个.NET应用程序,它们通过命名管道相互通信。第一次一切都很好,但是在发送第一条消息后,服务器将再次监听,WaitForConnection()方法抛出一个System.IO.Exception消息管道坏了。为什么我在这里得到这个异常(exception)?这是我第一次使用管道,但在过去使用套接字时,类似的模式对我有用。代码啊!服务器:usingSystem.IO.Pipes;staticvoidmain(){varpipe=newNamedPipeServerStream("pipename",PipeDirection.In);while(true){pipe.Listen(

jquery - 什么时候应该使用jQuery deferred的 "then"方法,什么时候应该使用 "pipe"方法?

jQuery的Deferred有两个函数可用于实现函数的异步链接:then()deferred.then(doneCallbacks,failCallbacks)Returns:DeferreddoneCallbacksAfunction,orarrayoffunctions,calledwhentheDeferredisresolved.failCallbacksAfunction,orarrayoffunctions,calledwhentheDeferredisrejected.pipe()deferred.pipe([doneFilter][,failFilter])Retur

go - 多次使用TCP连接返回 'broken pipe'错误

这个问题是关于go和它的net包的。我写了一个简单的tcp服务器处理一些RPC。客户端使用channet.Conn来管理客户端的所有tcp连接。服务器正在运行一个tcp监听器。代码如下:客户:packageserverimport("errors""log""net")vartcpPoolchannet.ConnfuncNewClient(connectionsint,addressstring){tcpPool=make(channet.Conn,connections)fori:=0;i>>>>>>>>>>>:",res)iferr!=nil{b[0]=ReErrorbreak}i

Golang io.Pipe 与 node.js 管道

我是golang的新手,我在理解go的io.Pipe时遇到了问题。这类似于node.js的.pipe吗?我应该如何使用它?是否可以将它与1个读取文件和一个写入文件一起使用?提前谢谢大家。 最佳答案 不,它们并不完全相似。io.Copy(datio.Writer,srcio.Reader)足以读写文件,如下所示:input:=bufio.NewReader(os.Stdin)output:=bufio.NewWriter(os.Stdout)//bufferoutputlikeCstdlibio.Copy(output,input)/

go - 使用 io.Pipes() 发送和接收消息

我在我的程序中使用os.Pipes(),但出于某种原因,每次我尝试从中写入或读取数据时,它都会给出错误的文件描述符错误。我做错了什么吗?下面是代码packagemainimport("fmt""os")funcmain(){writer,reader,err:=os.Pipe()iferr!=nil{fmt.Println(err)}_,err=writer.Write([]byte("hello"))iferr!=nil{fmt.Println(err)}vardata[]byte_,err=reader.Read(data)iferr!=nil{fmt.Println(err)}f

go - 使用 pipe 执行 go binary 时使用 scanln

我有以下代码:packagemainimport"fmt"funcmain(){ifscanln_test(){fmt.Println("Success!")}}funcscanln_test()bool{fmt.Print("Pleasetypeyesornoandthenpressenter[y/n]:")varresponsestringfmt.Scanln(&response)ifresponse=="y"{returntrue}elseifresponse=="n"{returnfalse}else{returnscanln_test()}}当通过管道执行编译后的二进制文件时

mysql - 去写 unix/tmp/mysql.sock : broken pipe when sending a lot of requests

我有一个可以进行多个MySQL查询的GoAPI端点。当端点收到少量请求时,它工作得很好。但是,我现在正在使用具有100个请求的apachebench对其进行测试。前100名全部通过。但是,第2个100导致出现这个错误2014/01/1512:08:03http:panicserving127.0.0.1:58602:runtimeerror:invalidmemoryaddressornilpointerdereferencegoroutine973[running]:net/http.func·009()/usr/local/Cellar/go/1.2/libexec/src/pkg

logging - os.Pipe 无法按预期使用日志包

我有一段代码设置了一个os.Pipe来捕获Stdout/Stderr:https://github.com/sevagh/stdcap/blob/master/stdcap.go//Captureexecutesf()andreturnsthecaptureddatafunc(s*stdcap)Capture(ffunc())string{s.mu.Lock()defers.mu.Unlock()varold,r,w*os.Fileifs.out{old=os.Stdoutr,w,_=os.Pipe()os.Stdout=w}else{old=os.Stderrr,w,_=os.Pip

go - Go io.Pipe 的缓冲版本

是否有io.Pipe的缓冲版本?(在标准库或第三方库中)在我自己推出之前?上下文:我正在尝试使用thissolution解析bzip2压缩的json数据,解压和解析是并行的,但是发现提速很小。解析未压缩的数据每百万条记录大约需要22秒。解压缩这么多数据大约需要相同的时间。正如预期的那样,在单个线程上执行这些操作大约需要44秒。使用上述解决方案大约需要41秒。io.Pipe的文档说:ReadsandWritesonthepipearematchedonetooneexceptwhenmultipleReadsareneededtoconsumeasingleWrite.Thatis,ea

go - 为什么即使达到 EOF io.Pipe() 也会继续阻塞?

在使用子进程并通过管道读取标准输出时,我注意到了一些有趣的行为。如果我使用io.Pipe()读取通过os/exec创建的子进程的标准输出,即使达到EOF,从该管道读取也会永远挂起(流程结束):cmd:=exec.Command("/bin/echo","Hello,world!")r,w:=io.Pipe()cmd.Stdout=wcmd.Start()io.Copy(os.Stdout,r)//Prints"Hello,World!"butneverreturns但是,如果我使用内置方法StdoutPipe()它会起作用:cmd:=exec.Command("/bin/echo","