Documentation ¶
Overview ¶
Transfer uses kcp to transport data betwween kcp client and server. By default, transfer split data into specified size trunck, and append md5 checksum after data. The recv side read data from network, check received data, append it to the output buffer(file). If there's anything wrong with the received data, transfer will ask the other side to resend the failed part. After receiving all the data, transfer will recheck all the recevied data with md5 again to make sure data completeness.
Index ¶
- Constants
- func AppendConfig(file *os.File, index uint32)
- func BinaryCompare(a, b []byte) int
- func CheckSum(data []byte) []byte
- func ChooseName(name string) (string, bool)
- func CloseFiles(files ...*os.File)
- func ConfigName(name string) string
- func EncodeMesg(mesg *msg.Transfer) ([]byte, error)
- func FillFile(file *os.File, total uint32) error
- func FlushFile(file, cfile *os.File, idx, pos uint32, data []byte, signal chan error)
- func LoadConfig(cfile *os.File, point *EndPoint) (bool, error)
- func OpenConfigName(name string) (*os.File, error)
- func ParseInitMesg(init *msg.SendInit, point *EndPoint) (bool, error)
- func ReadConfig(file *os.File) ([]byte, error)
- func ReadData(store []byte, sock Pipe) error
- func ReadFile(file *os.File, pos int, buffer []byte) (int, error)
- func ReadHeader(store []byte, sock Pipe) (uint32, error)
- func ReadMessage(dlen uint32, sock Pipe) ([]byte, error)
- func RecvFile(name string, dest string, raddr string) error
- func RecvFileProc(point *EndPoint, file, cfile *os.File, fill bool) error
- func SendFile(name string, raddr string) error
- func SendFileProc(point *EndPoint, info os.FileInfo, file *os.File) error
- func Serve(host string, dest string) error
- func WriteConfig(cfile *os.File, point *EndPoint) error
- type EndPoint
- func (end *EndPoint) AskIndex(size int) []uint32
- func (end *EndPoint) AskPartial(index []uint32) error
- func (end *EndPoint) Decode(data []byte) error
- func (end *EndPoint) Encode() []byte
- func (end *EndPoint) Error(code uint32) error
- func (end *EndPoint) ReadMessageTimeout(timeout time.Duration) (*msg.Transfer, error)
- func (end *EndPoint) RecvInit(name string, total, block, cnt uint32) error
- func (end *EndPoint) SendInit(info os.FileInfo, timeout time.Duration) error
- func (end *EndPoint) SendPartial(index uint32, data []byte) error
- func (end *EndPoint) SetInfo(total, block, cnt uint32)
- type Pipe
Constants ¶
View Source
const ( TIMEOUT = 30 * time.Second BLOCK_SIZE = 1024 * 16 ASK_WND = 5 )
Variables ¶
This section is empty.
Functions ¶
func AppendConfig ¶
func BinaryCompare ¶
func ChooseName ¶
func CloseFiles ¶
func ConfigName ¶
Types ¶
type EndPoint ¶
type EndPoint struct {
// contains filtered or unexported fields
}
func NewEndPoint ¶
func (*EndPoint) AskPartial ¶
func (*EndPoint) ReadMessageTimeout ¶
Click to show internal directories.
Click to hide internal directories.