rsocket

package module
v0.0.0-...-4a72eb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 7 Imported by: 2

README

rsocket

rsockets is a protocol over RDMA that supports a socket-level API for applications. rsocket APIs are intended to match the behavior of corresponding socket calls, except where noted. rsocket functions match the name and function signature of socket calls, with the exception that all function calls are prefixed with an 'r'.

This project encapsulates rsocket, provides an interface compatible with net.Conn, can be directly replaced with net.Conn, provides a more convenient interface, can directly use the encapsulated interface of rsocket, or use the interface of net.Conn. This project is based on RDMA, so the performance will be better than net.Conn.

GitHub GoDoc

This project is developing so don't use it in production environments.

Usage

Some examples of using rsocket are provided in the examples directory. The examples contains a simple TCP/UDP echo server and client.

Notice: udp doesn't work

Reference

Documentation

Index

Constants

View Source
const (
	AF_INET  = C.AF_INET
	AF_INET6 = C.AF_INET6
)

Socket domain constants

View Source
const (
	SOCK_STREAM = C.SOCK_STREAM
	SOCK_DGRAM  = C.SOCK_DGRAM
)

Socket type constants

View Source
const (
	IPPROTO_TCP = C.IPPROTO_TCP
	IPPROTO_UDP = C.IPPROTO_UDP
)

Protocol constants

View Source
const (
	SOL_RDMA    = C.SOL_RDMA
	RDMA_SQSIZE = C.RDMA_SQSIZE
	RDMA_RQSIZE = C.RDMA_RQSIZE
	RDMA_INLINE = C.RDMA_INLINE
	RDMA_ROUTE  = C.RDMA_ROUTE
)

RDMA specific socket options

View Source
const (
	// Socket level options
	SOL_SOCKET = syscall.SOL_SOCKET

	// Socket options
	SO_REUSEADDR = syscall.SO_REUSEADDR
	TCP_NODELAY  = syscall.TCP_NODELAY
	SO_ERROR     = syscall.SO_ERROR
	SO_SNDBUF    = syscall.SO_SNDBUF
	SO_RCVBUF    = syscall.SO_RCVBUF

	// RDMA specific options
	O_NONBLOCK = syscall.O_NONBLOCK
)

Socket option constants

Variables

This section is empty.

Functions

func Accept

func Accept(fd int) (int, syscall.Sockaddr, error)

Accept accepts a connection on the given socket

func Bind

func Bind(fd int, sa syscall.Sockaddr) error

Bind binds the socket to the given address

func Close

func Close(fd int) error

Close closes the socket

func Connect

func Connect(fd int, sa syscall.Sockaddr) error

Connect connects the socket to a remote address

func GetPeerName

func GetPeerName(fd int) (syscall.Sockaddr, error)

GetPeerName gets the address of the peer connected to the socket

func GetSockName

func GetSockName(fd int) (syscall.Sockaddr, error)

GetSockName gets the local address of the socket

func GetSockOpt

func GetSockOpt(fd, level, opt int, value unsafe.Pointer, len *uint32) error

GetSockOpt gets a socket option

func GetSockOptInt

func GetSockOptInt(fd, level, opt int) (int, error)

GetSockOptInt gets an integer socket option

func GetSocketError

func GetSocketError(fd int) error

GetSocketError gets SO_ERROR option

func Iomap

func Iomap(fd int, buf []byte, prot int, flags int, offset int64) (int64, error)

Iomap maps a file or device into memory

func Iounmap

func Iounmap(fd int, buf []byte) error

Iounmap unmaps a file or device from memory

func Iowrite

func Iowrite(fd int, buf []byte, offset int64, flags int) (int, error)

Iowrite writes data to a file or device at a specific offset

func Listen

func Listen(fd int, backlog int) error

Listen marks the socket as a passive socket

func Poll

func Poll(fds []unix.PollFd, timeout int) (int, error)

Poll polls the file descriptors

func Read

func Read(fd int, p []byte) (int, error)

Read reads data from the socket

func RecvFrom

func RecvFrom(fd int, p []byte, flags int) (int, syscall.Sockaddr, error)

RecvFrom receives data from a specific address

func RecvMsg

func RecvMsg(fd int, msg *syscall.Msghdr, flags int) (int, error)

RecvMsg receives a message from the socket

func Select

func Select(nfds int, readfds, writefds, exceptfds *syscall.FdSet, timeout *syscall.Timeval) (int, error)

Select waits for some file descriptors to become ready to perform I/O

func SendMsg

func SendMsg(fd int, msg *syscall.Msghdr, flags int) (int, error)

SendMsg sends a message on the socket

func SendTo

func SendTo(fd int, p []byte, flags int, sa syscall.Sockaddr) (int, error)

SendTo sends data to a specific address

func SetRDMAInline

func SetRDMAInline(fd int, value int) error

SetRDMAInline sets RDMA inline size

func SetRDMARQSize

func SetRDMARQSize(fd int, value int) error

SetRDMARQSize sets RDMA receive queue size

func SetRDMASQSize

func SetRDMASQSize(fd int, value int) error

SetRDMASQSize sets RDMA send queue size

func SetRecvBuffer

func SetRecvBuffer(fd int, value int) error

SetRecvBuffer sets SO_RCVBUF option

func SetReuseAddr

func SetReuseAddr(fd int, value bool) error

SetReuseAddr sets SO_REUSEADDR option

func SetSendBuffer

func SetSendBuffer(fd int, value int) error

SetSendBuffer sets SO_SNDBUF option

func SetSockOpt

func SetSockOpt(fd, level, opt int, value unsafe.Pointer, len uint32) error

SetSockOpt sets a socket option

func SetSockOptInt

func SetSockOptInt(fd, level, opt, value int) error

SetSockOptInt sets an integer socket option

func SetTCPNoDelay

func SetTCPNoDelay(fd int, value bool) error

SetTCPNoDelay sets TCP_NODELAY option

func Socket

func Socket(domain, typ, protocol int) (int, error)

Socket creates a new RDMA socket

func Write

func Write(fd int, p []byte) (int, error)

Write writes data to the socket

func Writev

func Writev(fd int, iov []syscall.Iovec) (int, error)

Writev writes multiple buffers to the socket

Types

type OptionSocketFn

type OptionSocketFn func(fd int) error

func WithLocalAddr

func WithLocalAddr(ip string, port int) OptionSocketFn

type TCPConn

type TCPConn struct {
	// contains filtered or unexported fields
}

func DialTCP

func DialTCP(address string, optFns ...OptionSocketFn) (*TCPConn, error)

DialTCP connects to the address on the named network based on rsocket.

func (*TCPConn) Close

func (c *TCPConn) Close() error

Close closes the connection.

func (*TCPConn) File

func (c *TCPConn) File() int

File returns the connection's file descriptor.

func (*TCPConn) LocalAddr

func (c *TCPConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*TCPConn) Read

func (c *TCPConn) Read(p []byte) (int, error)

Read reads data from the connection.

func (*TCPConn) RemoteAddr

func (c *TCPConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*TCPConn) SetDeadline

func (c *TCPConn) SetDeadline(time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. not implementation.

func (*TCPConn) SetReadDeadline

func (c *TCPConn) SetReadDeadline(time.Time) error

SetReadDeadline sets the read deadline on the connection. not implementation.

func (*TCPConn) SetWriteDeadline

func (c *TCPConn) SetWriteDeadline(time.Time) error

SetWriteDeadline sets the write deadline on the connection. not implementation.

func (*TCPConn) Write

func (c *TCPConn) Write(p []byte) (int, error)

Write writes data to the connection.

type TCPListener

type TCPListener struct {
	// contains filtered or unexported fields
}

TCPListener is a TCP network listener baseded on rsocket.

func NewTCPListener

func NewTCPListener(ip string, port int, backlog int, optFns ...OptionSocketFn) (*TCPListener, error)

NewTCPListener creates a new TCPListener. It binds the listener to the given ip and port.

func (*TCPListener) Accept

func (l *TCPListener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*TCPListener) Addr

func (l *TCPListener) Addr() net.Addr

Addr returns the listener's network address.

func (*TCPListener) Close

func (l *TCPListener) Close() error

Close closes the listener.

func (*TCPListener) File

func (l *TCPListener) File() int

File returns the listener's file descriptor.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL