From 998a23c9634b3eeeb6cef1d658d98da94f3cd23c Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 10 Jul 2019 20:04:01 +0100 Subject: [PATCH] Functional code for link --- network/link/default.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/network/link/default.go b/network/link/default.go index 369f97b7..f0d01ecd 100644 --- a/network/link/default.go +++ b/network/link/default.go @@ -44,8 +44,8 @@ type link struct { func newLink(options options.Options) *link { // default values var sock transport.Socket + var addr string id := "local" - addr := "127.0.0.1:10001" tr := transport.DefaultTransport lid, ok := options.Values().Get("link.id") @@ -144,14 +144,20 @@ func (l *link) Connect() error { l.Unlock() return nil } + defer l.Unlock() // replace closed l.closed = make(chan bool) + // assume existing socket + if len(l.addr) == 0 { + go l.process() + return nil + } + // dial the endpoint c, err := l.transport.Dial(l.addr) if err != nil { - l.Unlock() return nil }