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


Golang Socket.Recv方法代碼示例

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


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

示例1: zmqToWebsocket

// listen on a zmq SUB socket
// and shovel messages from it out to the websockets
func zmqToWebsocket(subsocket zmq.Socket) {
	for {
		address, _ := subsocket.Recv(0)
		content, _ := subsocket.Recv(0)
		fmt.Println("received a zmq message")
		fmt.Println(string(address))
		fmt.Println(string(content))
		runningRoom.SendMessage(envelope{string(address), string(content)})
	}
}
開發者ID:nikolas,項目名稱:windsock,代碼行數:12,代碼來源:windsock.go

示例2: zmqToWebsocket

// listen on a zmq SUB socket
// and shovel messages from it out to the websockets
func zmqToWebsocket(subsocket zmq.Socket) {
	for {
		address, _ := subsocket.Recv(0)
		content, _ := subsocket.Recv(0)
		log.WithFields(log.Fields{
			"address": string(address),
			"content": string(content),
		}).Info("received a zmq message")
		runningRoom.SendMessage(envelope{string(address), string(content)})
	}
}
開發者ID:thraxil,項目名稱:windsock,代碼行數:13,代碼來源:windsock.go

示例3: 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:patrickToca,項目名稱:zmq2,代碼行數:23,代碼來源:identity.go

示例4: sendMessage

// send a message to the zmq PUB socket
func sendMessage(reqsocket zmq.Socket, e envelope) {
	serialized_envelope, _ := json.Marshal(e)
	reqsocket.Send(string(serialized_envelope), 0)
	// wait for a reply
	reqsocket.Recv(0)
}
開發者ID:nikolas,項目名稱:windsock,代碼行數:7,代碼來源:windsock.go


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