func WriteFile(c *net.UnixConn, file *os.File, timeout time.Duration) error { if timeout > 0 { deadline := time.Now().Add(timeout) if err := c.SetWriteDeadline(deadline); err != nil { return err } } oob := syscall.UnixRights(int(file.Fd())) _, _, err := c.WriteMsgUnix(nil, oob, nil) return err }