diff options
author | David du Colombier <0intro@gmail.com> | 2019-09-06 11:54:44 -0700 |
---|---|---|
committer | David du Colombier <0intro@gmail.com> | 2019-09-06 11:54:44 -0700 |
commit | 63ae9ed53a04fac853693f8d319a4bbc1f6b5f49 (patch) | |
tree | 3d46d23ae719fd13cd280083316d665f14ea06fb /sys/src/libventi/conn.c | |
parent | 8cbe3772c45431b962971e45581d831772a85947 (diff) |
sys/src/libventi: implement vtreconn and vtredial functions
Diffstat (limited to 'sys/src/libventi/conn.c')
-rw-r--r-- | sys/src/libventi/conn.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/src/libventi/conn.c b/sys/src/libventi/conn.c index e488c6db6..2a8f67b96 100644 --- a/sys/src/libventi/conn.c +++ b/sys/src/libventi/conn.c @@ -27,6 +27,28 @@ vtconn(int infd, int outfd) return z; } +int +vtreconn(VtConn *z, int infd, int outfd) +{ + NetConnInfo *nci; + + z->state = VtStateAlloc; + if(z->infd >= 0) + close(z->infd); + z->infd = infd; + if(z->outfd >= 0) + close(z->outfd); + z->outfd = outfd; + nci = getnetconninfo(nil, infd); + if(nci == nil) + snprint(z->addr, sizeof z->addr, "/dev/fd/%d", infd); + else{ + strecpy(z->addr, z->addr+sizeof z->addr, nci->raddr); + freenetconninfo(nci); + } + return 0; +} + void vtfreeconn(VtConn *z) { |