npipe:用纯 Go 编写的 Windows 命名管道实现

  • l1_660834
    了解作者
  • 15.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-04 06:49
    上传日期
管道 包 npipe 提供了一个围绕 Windows 命名管道的纯 Go 包装器。 Windows 命名管道文档: : 请注意,代码位于分支),但应导入为 gopkg.in/natefinch/npipe.v2(包名称仍为 npipe)。 npipe 提供了一个基于 stdlib 的 net 包的接口,带有 Dial、Listen 和 Accept 函数,以及相关的 net.Conn 和 net.Listener 实现。 它支持通过连接进行 rpc。 笔记 由于 Windows API 的限制,读取/写入连接的截止日期仅在 Windows Vista/Server 2008 及更高版本中有效。 管道仅支持字节模式(不支持消息模式) 例子 Dial 函数将客户端连接到命名管道: conn, err := npipe.Dial(`\\.\pipe\mypipename`) i
npipe-v2.zip
  • npipe-2
  • npipe_windows.go
    15.6KB
  • LICENSE.txt
    1.1KB
  • znpipe_windows_amd64.go
    3.4KB
  • znpipe_windows_386.go
    3.4KB
  • doc.go
    1.6KB
  • README.md
    6KB
  • example_windows_test.go
    945B
  • npipe_windows_test.go
    17KB
  • .gitignore
    252B
内容介绍
npipe [![Build status](https://ci.appveyor.com/api/projects/status/00vuepirsot29qwi)](https://ci.appveyor.com/project/natefinch/npipe) [![GoDoc](https://godoc.org/gopkg.in/natefinch/npipe.v2?status.svg)](https://godoc.org/gopkg.in/natefinch/npipe.v2) ===== Package npipe provides a pure Go wrapper around Windows named pipes. Windows named pipe documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365780 Note that the code lives at https://github.com/natefinch/npipe (v2 branch) but should be imported as gopkg.in/natefinch/npipe.v2 (the package name is still npipe). npipe provides an interface based on stdlib's net package, with Dial, Listen, and Accept functions, as well as associated implementations of net.Conn and net.Listener. It supports rpc over the connection. ### Notes * Deadlines for reading/writing to the connection are only functional in Windows Vista/Server 2008 and above, due to limitations with the Windows API. * The pipes support byte mode only (no support for message mode) ### Examples The Dial function connects a client to a named pipe: conn, err := npipe.Dial(`\\.\pipe\mypipename`) if err != nil { <handle error> } fmt.Fprintf(conn, "Hi server!\n") msg, err := bufio.NewReader(conn).ReadString('\n') ... The Listen function creates servers: ln, err := npipe.Listen(`\\.\pipe\mypipename`) if err != nil { // handle error } for { conn, err := ln.Accept() if err != nil { // handle error continue } go handleConnection(conn) } ## Variables ``` go var ErrClosed = PipeError{"Pipe has been closed.", false} ``` ErrClosed is the error returned by PipeListener.Accept when Close is called on the PipeListener. ## type PipeAddr ``` go type PipeAddr string ``` PipeAddr represents the address of a named pipe. ### func (PipeAddr) Network ``` go func (a PipeAddr) Network() string ``` Network returns the address's network name, "pipe". ### func (PipeAddr) String ``` go func (a PipeAddr) String() string ``` String returns the address of the pipe ## type PipeConn ``` go type PipeConn struct { // contains filtered or unexported fields } ``` PipeConn is the implementation of the net.Conn interface for named pipe connections. ### func Dial ``` go func Dial(address string) (*PipeConn, error) ``` Dial connects to a named pipe with the given address. If the specified pipe is not available, it will wait indefinitely for the pipe to become available. The address must be of the form \\.\\pipe\<name> for local pipes and \\<computer>\pipe\<name> for remote pipes. Dial will return a PipeError if you pass in a badly formatted pipe name. Examples: // local pipe conn, err := Dial(`\\.\pipe\mypipename`) // remote pipe conn, err := Dial(`\\othercomp\pipe\mypipename`) ### func DialTimeout ``` go func DialTimeout(address string, timeout time.Duration) (*PipeConn, error) ``` DialTimeout acts like Dial, but will time out after the duration of timeout ### func (\*PipeConn) Close ``` go func (c *PipeConn) Close() error ``` Close closes the connection. ### func (\*PipeConn) LocalAddr ``` go func (c *PipeConn) LocalAddr() net.Addr ``` LocalAddr returns the local network address. ### func (\*PipeConn) Read ``` go func (c *PipeConn) Read(b []byte) (int, error) ``` Read implements the net.Conn Read method. ### func (\*PipeConn) RemoteAddr ``` go func (c *PipeConn) RemoteAddr() net.Addr ``` RemoteAddr returns the remote network address. ### func (\*PipeConn) SetDeadline ``` go func (c *PipeConn) SetDeadline(t time.Time) error ``` SetDeadline implements the net.Conn SetDeadline method. Note that timeouts are only supported on Windows Vista/Server 2008 and above ### func (\*PipeConn) SetReadDeadline ``` go func (c *PipeConn) SetReadDeadline(t time.Time) error ``` SetReadDeadline implements the net.Conn SetReadDeadline method. Note that timeouts are only supported on Windows Vista/Server 2008 and above ### func (\*PipeConn) SetWriteDeadline ``` go func (c *PipeConn) SetWriteDeadline(t time.Time) error ``` SetWriteDeadline implements the net.Conn SetWriteDeadline method. Note that timeouts are only supported on Windows Vista/Server 2008 and above ### func (\*PipeConn) Write ``` go func (c *PipeConn) Write(b []byte) (int, error) ``` Write implements the net.Conn Write method. ## type PipeError ``` go type PipeError struct { // contains filtered or unexported fields } ``` PipeError is an error related to a call to a pipe ### func (PipeError) Error ``` go func (e PipeError) Error() string ``` Error implements the error interface ### func (PipeError) Temporary ``` go func (e PipeError) Temporary() bool ``` Temporary implements net.AddrError.Temporary() ### func (PipeError) Timeout ``` go func (e PipeError) Timeout() bool ``` Timeout implements net.AddrError.Timeout() ## type PipeListener ``` go type PipeListener struct { // contains filtered or unexported fields } ``` PipeListener is a named pipe listener. Clients should typically use variables of type net.Listener instead of assuming named pipe. ### func Listen ``` go func Listen(address string) (*PipeListener, error) ``` Listen returns a new PipeListener that will listen on a pipe with the given address. The address must be of the form \\.\pipe\<name> Listen will return a PipeError for an incorrectly formatted pipe name. ### func (\*PipeListener) Accept ``` go func (l *PipeListener) Accept() (net.Conn, error) ``` Accept implements the Accept method in the net.Listener interface; it waits for the next call and returns a generic net.Conn. ### func (\*PipeListener) AcceptPipe ``` go func (l *PipeListener) AcceptPipe() (*PipeConn, error) ``` AcceptPipe accepts the next incoming call and returns the new connection. ### func (\*PipeListener) Addr ``` go func (l *PipeListener) Addr() net.Addr ``` Addr returns the listener's network address, a PipeAddr. ### func (\*PipeListener) Close ``` go func (l *PipeListener) Close() error ``` Close stops listening on the address. Already Accepted connections are not closed.
评论
    相关推荐
    • windows rpc编程实现
      在单一程序中实现服务器和客户端 其中使用dll动态链接库来建立与应用程序的连接。
    • Widnwos RPC Demo
      windows RPC远程过程调用的Demo,亲测可用。Windows RPC Demo实现。 Windows RPC Demo实现。 Windows RPC Demo实现。 Windows RPC Demo实现。 Windows RPC Demo实现。
    • 多版本windows溢出工具(xp.exe)
      此工具可远程利用DCOM RPC缓冲区溢出,可以溢出多版本的windows: - 0 Windows 2000 SP0 (english) - 1 Windows 2000 SP0 (english2) - 2 Windows 2000 SP1 (english) - 3 Windows 2000 SP2 (english) - 4 Windows ...
    • rpc测试工具
      针对微软RPC漏洞的攻击工具,对windows2000(sp4以前版本)、windowsXP(sp2以前版本)有效。本工具旨在用于测试windows漏洞,不得用于其它目的。
    • Windows与Linux的RPC通信
      Windows与Linux的RPC通信的一个简单例子 。 Windows与Linux的RPC通信源码
    • oncrpc-win-proj.rar
      包含oncrpcwindows源码包和oncrpc windows的测试程序(基于vs2013工程)。
    • Windows RPC入门程序
      RPC入门程序,经VS2010调试通过并正常运行。源于微软官网。有修改。
    • frame-rpc:使用postMessage在iframe和Windows之间进行rpc,无需序列化
      使用postMessage在iframe和Windows之间进行rpc,无需序列化 例子 公开页面中将作为iframe加载的方法: var RPC = require ( 'frame-rpc' ) ; var origin = document . referrer ; var rpc = RPC ( window , window...
    • Windows rpc 程序
      该程序使用windows ipc 实现客户端对服务端远程过程调用。其中还涉及到c语言对mysql数据库的连接以及查询等操作。
    • RPC example
      RPC的使用示例,包括客户端和服务端,vs2008