本文整理汇总了Golang中net.UnixConn.ReadFrom方法的典型用法代码示例。如果您正苦于以下问题:Golang UnixConn.ReadFrom方法的具体用法?Golang UnixConn.ReadFrom怎么用?Golang UnixConn.ReadFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.UnixConn
的用法示例。
在下文中一共展示了UnixConn.ReadFrom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: run_queue
func (r *fake_conn) run_queue(conn *net.UnixConn) {
defer conn.Close()
for {
select {
case <-r.end:
return
default:
buffer := make([]byte, 1<<16)
conn.SetReadDeadline(time.Now().Add(1000 * time.Millisecond))
s, _, err := conn.ReadFrom(buffer)
switch t_err := err.(type) {
case nil:
case net.Error:
if !t_err.Timeout() {
panic(err)
}
default:
panic(err)
}
if s > 0 {
r.queue <- buffer[0:s]
}
}
}
}
示例2: readAndCompare
func readAndCompare(conn *net.UnixConn, want string) error {
buf := make([]byte, 128)
// File system events can take a long time to propagate
conn.SetDeadline(time.Now().Add(3 * time.Second))
if _, _, err := conn.ReadFrom(buf); err != nil {
return err
}
if have := string(bytes.Trim(buf, "\x00")); have != want {
return fmt.Errorf("expected %q, got %q", want, have)
}
return nil
}
示例3: cope_with
func (devlog *DevLogReader) cope_with(conn *net.UnixConn, buffer []byte, dest chan<- Message) {
_, _, err := conn.ReadFrom(buffer)
if err != nil {
devlog.errchan <- &InputError{devlog.Driver, devlog.Id, "ReadFrom " + devlog.Devlog, err}
return
}
line := rtrim_blank(buffer)
if len(line) == 0 {
return
}
l, err := parse_3164_or_5424(devlog.Id, line)
if err != nil {
devlog.errchan <- &InputError{devlog.Driver, devlog.Id, "parse_3164_or_5424 " + devlog.Devlog, err}
return
}
dest <- l
}
示例4: cope_with
func (jrnl *JournalReader) cope_with(conn *net.UnixConn, buffer []byte, dest chan<- Message) {
_, _, err := conn.ReadFrom(buffer)
if err != nil {
jrnl.errchan <- &InputError{jrnl.Driver, jrnl.Id, "ReadFrom " + jrnl.Journald, err}
return
}
line := rtrim_blank(buffer)
if len(line) == 0 {
return
}
l, err := parse_3164_or_5424(jrnl.Id, line)
if err != nil {
jrnl.errchan <- &InputError{jrnl.Driver, jrnl.Id, "parse_3164_or_5424 " + jrnl.Journald, err}
return
}
dest <- l
}