當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Socket.GetRcvmore方法代碼示例

本文整理匯總了Golang中github.com/pebbe/zmq3.Socket.GetRcvmore方法的典型用法代碼示例。如果您正苦於以下問題:Golang Socket.GetRcvmore方法的具體用法?Golang Socket.GetRcvmore怎麽用?Golang Socket.GetRcvmore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/pebbe/zmq3.Socket的用法示例。


在下文中一共展示了Socket.GetRcvmore方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: dump

func dump(soc *zmq.Socket) {
    fmt.Println("----------------------------------------")
    for {
        //  Process all parts of the message
        message, _ := soc.Recv(0)

        //  Dump the message as text or binary
        fmt.Printf("[%03d] ", len(message))
        if all_char.MatchString(message) {
            fmt.Print(message)
        } else {
            for i := 0; i < len(message); i++ {
                fmt.Printf("%02X ", message[i])
            }
        }
        fmt.Println()

        more, _ := soc.GetRcvmore()
        if !more {
            break
        }
    }
}
開發者ID:rrudduck,項目名稱:golang-stuff,代碼行數:23,代碼來源:identity.go

示例2: bounce

func bounce(server, client *zmq.Socket) (msg string, err error) {

    content := "12345678ABCDEFGH12345678abcdefgh"

    //  Send message from client to server
    rc, err := client.Send(content, zmq.SNDMORE|zmq.DONTWAIT)
    if err != nil {
        return "client.Send SNDMORE|DONTWAIT:", err
    }
    if rc != 32 {
        return "client.Send SNDMORE|DONTWAIT:", err32
    }

    rc, err = client.Send(content, zmq.DONTWAIT)
    if err != nil {
        return "client.Send DONTWAIT:", err
    }
    if rc != 32 {
        return "client.Send DONTWAIT:", err32
    }

    //  Receive message at server side
    msg, err = server.Recv(0)
    if err != nil {
        return "server.Recv 1:", err
    }

    //  Check that message is still the same
    if msg != content {
        return "server.Recv 1:", errors.New(fmt.Sprintf("%q != %q", msg, content))
    }

    rcvmore, err := server.GetRcvmore()
    if err != nil {
        return "server.GetRcvmore 1:", err
    }
    if !rcvmore {
        return "server.GetRcvmore 1:", errors.New(fmt.Sprint("rcvmore ==", rcvmore))
    }

    //  Receive message at server side
    msg, err = server.Recv(0)
    if err != nil {
        return "server.Recv 2:", err
    }

    //  Check that message is still the same
    if msg != content {
        return "server.Recv 2:", errors.New(fmt.Sprintf("%q != %q", msg, content))
    }

    rcvmore, err = server.GetRcvmore()
    if err != nil {
        return "server.GetRcvmore 2:", err
    }
    if rcvmore {
        return "server.GetRcvmore 2:", errors.New(fmt.Sprint("rcvmore == ", rcvmore))
    }

    // The same, from server back to client

    //  Send message from server to client
    rc, err = server.Send(content, zmq.SNDMORE)
    if err != nil {
        return "server.Send SNDMORE:", err
    }
    if rc != 32 {
        return "server.Send SNDMORE:", err32
    }

    rc, err = server.Send(content, 0)
    if err != nil {
        return "server.Send 0:", err
    }
    if rc != 32 {
        return "server.Send 0:", err32
    }

    //  Receive message at client side
    msg, err = client.Recv(0)
    if err != nil {
        return "client.Recv 1:", err
    }

    //  Check that message is still the same
    if msg != content {
        return "client.Recv 1:", errors.New(fmt.Sprintf("%q != %q", msg, content))
    }

    rcvmore, err = client.GetRcvmore()
    if err != nil {
        return "client.GetRcvmore 1:", err
    }
    if !rcvmore {
        return "client.GetRcvmore 1:", errors.New(fmt.Sprint("rcvmore ==", rcvmore))
    }

    //  Receive message at client side
    msg, err = client.Recv(0)
    if err != nil {
//.........這裏部分代碼省略.........
開發者ID:pebbe,項目名稱:zmq3,代碼行數:101,代碼來源:zmq3_test.go

示例3: bounce

func bounce(server, client *zmq.Socket) {

    content := "12345678ABCDEFGH12345678abcdefgh"

    //  Send message from client to server
    rc, err := client.Send(content, zmq.SNDMORE)
    if checkErr(err) {
        return
    }
    if rc != 32 {
        checkErr(errors.New("rc != 32"))
    }

    rc, err = client.Send(content, 0)
    if checkErr(err) {
        return
    }
    if rc != 32 {
        checkErr(errors.New("rc != 32"))
    }

    //  Receive message at server side
    msg, err := server.Recv(0)
    if checkErr(err) {
        return
    }

    //  Check that message is still the same
    if msg != content {
        checkErr(errors.New(fmt.Sprintf("%q != %q", msg, content)))
    }

    rcvmore, err := server.GetRcvmore()
    if checkErr(err) {
        return
    }
    if !rcvmore {
        checkErr(errors.New(fmt.Sprint("rcvmore ==", rcvmore)))
        return
    }

    //  Receive message at server side
    msg, err = server.Recv(0)
    if checkErr(err) {
        return
    }

    //  Check that message is still the same
    if msg != content {
        checkErr(errors.New(fmt.Sprintf("%q != %q", msg, content)))
    }

    rcvmore, err = server.GetRcvmore()
    if checkErr(err) {
        return
    }
    if rcvmore {
        checkErr(errors.New(fmt.Sprint("rcvmore == ", rcvmore)))
        return
    }

    // The same, from server back to client

    //  Send message from server to client
    rc, err = server.Send(content, zmq.SNDMORE)
    if checkErr(err) {
        return
    }
    if rc != 32 {
        checkErr(errors.New("rc != 32"))
    }

    rc, err = server.Send(content, 0)
    if checkErr(err) {
        return
    }
    if rc != 32 {
        checkErr(errors.New("rc != 32"))
    }

    //  Receive message at client side
    msg, err = client.Recv(0)
    if checkErr(err) {
        return
    }

    //  Check that message is still the same
    if msg != content {
        checkErr(errors.New(fmt.Sprintf("%q != %q", msg, content)))
    }

    rcvmore, err = client.GetRcvmore()
    if checkErr(err) {
        return
    }
    if !rcvmore {
        checkErr(errors.New(fmt.Sprint("rcvmore ==", rcvmore)))
        return
    }

//.........這裏部分代碼省略.........
開發者ID:Dragomir-Ivanov,項目名稱:zmq3,代碼行數:101,代碼來源:zmq3_test.go


注:本文中的github.com/pebbe/zmq3.Socket.GetRcvmore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。