Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/way29/cake
A cake for for connect local file or socket Written by golang
https://github.com/way29/cake
Last synced: about 2 months ago
JSON representation
A cake for for connect local file or socket Written by golang
- Host: GitHub
- URL: https://github.com/way29/cake
- Owner: WAY29
- Created: 2020-12-08T05:02:36.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T05:08:42.000Z (over 2 years ago)
- Last Synced: 2024-06-20T17:34:45.266Z (6 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Cake
***A cake for for connect local file or socket***## Depends
- emperror.dev/errors v0.8.0
- github.com/jawher/mow.cli v1.2.0## Usage
```go
package mainimport (
"fmt""github.com/WAY29/cake/api"
)func main() {
c := api.Connect("./test.exe") // local file
// c := api.Connect("1.1.1.1:2333") // remote socket
n, data := c.Recv(100, 10) // recvnumber, timeout
if n > 0 {
fmt.Print(string(data))
}
//n, err := c.Sendline([]byte("qwe")) // send data
n, err := c.Sendline([]byte("qwe")) // send data with '\n'
if err != nil {
fmt.Println("error", err)
}data = c.Recvuntil([]byte("we"), true) // recv data until bytes, drops utilsbytes if set true
fmt.Print(string(data))
c.InteractiveR() // interactive with it, use :r to reconnect, :exit to exit
c.Close() // close connect
}```