diff options
author | David du Colombier <0intro@gmail.com> | 2011-11-08 09:02:31 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2011-11-08 09:02:31 -0500 |
commit | 4544da52005bf0af3bb05a73f4e02ce35117aae0 (patch) | |
tree | a9e3f60b9c118a578ac6d9e017979cd938a665bc /src/libventi/conn.c | |
parent | 36c242dd868672ae9c6705622ef1e7dbb84dbbac (diff) | |
download | plan9port-4544da52005bf0af3bb05a73f4e02ce35117aae0.tar.gz plan9port-4544da52005bf0af3bb05a73f4e02ce35117aae0.tar.bz2 plan9port-4544da52005bf0af3bb05a73f4e02ce35117aae0.zip |
libventi: add functions reconn and redial for use with fossil
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5325046
Diffstat (limited to 'src/libventi/conn.c')
-rw-r--r-- | src/libventi/conn.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libventi/conn.c b/src/libventi/conn.c index e488c6db..2a8f67b9 100644 --- a/src/libventi/conn.c +++ b/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) { |