Documentation
¶
Overview ¶
Package transfer provides client and server for file transfer.
Package transfer provides client and server for file transfer.
Package transfer provides client and server for file transfer.
Package transfer provides client and server for file transfer.
Package transfer provides client and server for file transfer.
Package transfer provides client and server for file transfer.
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) CloseSession(sessionId SessionId) error
- func (c *Client) Dial() error
- func (c *Client) Download(filename, saveFile string) error
- func (c *Client) DownloadAt(filename, saveFile string, blockId int) error
- func (c *Client) GetBlock(sessionId SessionId, blockId int) ([]byte, error)
- func (c *Client) Open(filename string) (SessionId, error)
- func (c *Client) Read(sessionId SessionId, buf []byte) (int, error)
- func (c *Client) ReadAt(sessionId SessionId, offset int64, size int) ([]byte, error)
- func (c *Client) Stat(filename string) (*StatResponse, error)
- type FileRequest
- type GetRequest
- type GetResponse
- type ReadCloser
- type ReadRequest
- type ReadResponse
- type Request
- type Response
- type Rpc
- type Server
- type Session
- type SessionId
- type StatResponse
Constants ¶
const (
// BLOCK_SIZE is the size of each block to be transferred.
BLOCK_SIZE = 512 * 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Addr string
// contains filtered or unexported fields
}
Client is a file transfer client.
func (*Client) CloseSession ¶
CloseSession closes a session on the server.
func (*Client) DownloadAt ¶
DownloadAt downloads a file from the server, starting from a specific block.
type FileRequest ¶
type FileRequest struct {
Filename string
}
FileRequest is a request with a filename.
type GetRequest ¶
GetRequest is a request to get a block of data.
type GetResponse ¶
GetResponse is a response containing a block of data.
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser is a wrapper around the client to provide an io.ReadCloser interface.
func NewReadCloser ¶
func NewReadCloser(client *Client, sessionId SessionId) *ReadCloser
NewReadCloser creates a new ReadCloser.
func (*ReadCloser) Read ¶
func (r *ReadCloser) Read(buf []byte) (int, error)
Read reads data from the stream.
func (*ReadCloser) SessionId ¶
func (r *ReadCloser) SessionId() SessionId
SessionId returns the session ID.
type ReadRequest ¶
ReadRequest is a request to read data.
type ReadResponse ¶
ReadResponse is a response containing data read from a file.
type Rpc ¶
type Rpc struct {
// contains filtered or unexported fields
}
Rpc is the RPC service.
func (*Rpc) Open ¶
func (r *Rpc) Open(req FileRequest, res *Response) error
Open opens a file and returns a session ID.
func (*Rpc) Read ¶
func (r *Rpc) Read(req ReadRequest, res *ReadResponse) error
Read reads data from a file.
func (*Rpc) ReadAt ¶
func (r *Rpc) ReadAt(req ReadRequest, res *ReadResponse) error
ReadAt reads data from a file at a specific offset.
func (*Rpc) Stat ¶
func (r *Rpc) Stat(req FileRequest, res *StatResponse) error
Stat returns file information.
type Server ¶
Server is a file transfer server.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages file transfer sessions.
type StatResponse ¶
StatResponse is a response containing file information.
func (*StatResponse) IsDir ¶
func (r *StatResponse) IsDir() bool
IsDir returns true if the file is a directory.