本文整理汇总了Golang中github.com/exodus23-13/zooms/go/unixsocket.Usock.Close方法的典型用法代码示例。如果您正苦于以下问题:Golang Usock.Close方法的具体用法?Golang Usock.Close怎么用?Golang Usock.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/exodus23-13/zooms/go/unixsocket.Usock
的用法示例。
在下文中一共展示了Usock.Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleClientConnection
// see docs/client_master_handshake.md
func handleClientConnection(tree *processtree.ProcessTree, usock *unixsocket.Usock) {
defer usock.Close()
// we have established first contact to the client.
command, clientPid, arguments, err := receiveCommandArgumentsAndPid(usock, nil)
commandNode, slaveNode, err := findCommandAndSlaveNodes(tree, command, err)
if err != nil {
// connection was established, no data was sent. Ignore.
return
}
command = commandNode.Name // resolve aliases
clientFile, err := receiveTTY(usock, err)
defer clientFile.Close()
if err == nil && slaveNode.Error != "" {
// we can skip steps 3-5 as they deal with the command process we're not spawning.
// Write a fake pid (step 6)
usock.WriteMessage("0")
// Write the error message to the terminal
clientFile.Write([]byte(slaveNode.Error))
// Skip step 7, and write an exit code to the client (step 8)
usock.WriteMessage("1")
return
}
commandUsock, err := bootNewCommand(slaveNode, command, err)
defer commandUsock.Close()
err = sendClientPidAndArgumentsToCommand(commandUsock, clientPid, arguments, err)
err = sendTTYToCommand(commandUsock, clientFile, err)
cmdPid, err := receivePidFromCommand(commandUsock, err)
err = sendCommandPidToClient(usock, cmdPid, err)
exitStatus, err := receiveExitStatus(commandUsock, err)
err = sendExitStatus(usock, exitStatus, err)
if err != nil {
slog.Error(err)
}
// Done! Hooray!
}