Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,43 @@ This library is designed to be integrated in your program.
4. On Windows, docker daemon data dir must be provided for ServeTCP and ServeWindows functions.
On Unix, this parameter is ignored.

### Example using TCP sockets:
## Quickstart (using TCP sockets)

Here is a minimalist example to start the network driver on your host machine.
```go
import "github.com/docker/go-plugins-helpers/network"
package main

import (
"fmt"
"os"

"github.com/docker/go-plugins-helpers/network"
)

type MyNetworkDriver struct {
network.Driver
}

func main() {
d := MyNetworkDriver{}
h := network.NewHandler(d)
h.ServeTCP("test_network", ":8080", "")
// on windows:
h.ServeTCP("test_network", ":8080", WindowsDefaultDaemonRootDir())
h := network.NewHandler(&d)
err := h.ServeTCP("test_network", "localhost:8080", "", nil)
if err != nil {
fmt.Printf("error occurred: %s\n", err.Error())
os.Exit(1)
}
}

```

You can test this out by the following:
```bash
$ curl http://localhost:8080/Plugin.Activate
{"Implements": ["NetworkDriver"]}
```

## Further Examples

### Example using Unix sockets:

```go
Expand Down