summaryrefslogtreecommitdiff
path: root/appl/cmd/listen.b
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
committerforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
commit9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (patch)
tree4f835b35913acfb115b15ea4f1c6af40fd77ab54 /appl/cmd/listen.b
parent16501eaf1cb642b80d7fa0236407a27aecb35b02 (diff)
emu/Nt/ipif.c
Diffstat (limited to 'appl/cmd/listen.b')
-rw-r--r--appl/cmd/listen.b33
1 files changed, 19 insertions, 14 deletions
diff --git a/appl/cmd/listen.b b/appl/cmd/listen.b
index 25869223..5a06892d 100644
--- a/appl/cmd/listen.b
+++ b/appl/cmd/listen.b
@@ -7,6 +7,8 @@ include "keyring.m";
keyring: Keyring;
include "security.m";
auth: Auth;
+include "dial.m";
+ dial: Dial;
include "sh.m";
sh: Sh;
Context: import sh;
@@ -31,6 +33,9 @@ init(drawctxt: ref Draw->Context, argv: list of string)
auth = load Auth Auth->PATH;
if (auth == nil)
badmodule(Auth->PATH);
+ dial = load Dial Dial->PATH;
+ if (dial == nil)
+ badmodule(Dial->PATH);
sh = load Sh Sh->PATH;
if (sh == nil)
badmodule(Sh->PATH);
@@ -120,8 +125,8 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
sys->pctl(Sys->FORKFD, nil);
ctxt := Context.new(drawctxt);
- (ok, acon) := sys->announce(addr);
- if (ok == -1) {
+ acon := dial->announce(addr);
+ if (acon == nil) {
sys->fprint(stderr(), "listen: failed to announce on '%s': %r\n", addr);
sync <-= "cannot announce";
exit;
@@ -146,15 +151,15 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
sync <-= nil;
- listench := chan of (int, Sys->Connection);
- authch := chan of (string, Sys->Connection);
+ listench := chan of ref Dial->Connection;
+ authch := chan of (string, ref Dial->Connection);
spawn listener(listench, acon, addr);
for (;;) {
user := "";
- ccon: Sys->Connection;
+ ccon: ref Dial->Connection;
alt {
- (lok, c) := <-listench =>
- if (lok == -1){
+ c := <-listench =>
+ if (c == nil){
sync <-= "listen";
exit;
}
@@ -182,13 +187,13 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
}
-listener(listench: chan of (int, Sys->Connection), c: Sys->Connection, addr: string)
+listener(listench: chan of ref Dial->Connection, c: ref Dial->Connection, addr: string)
{
for (;;) {
- (ok, nc) := sys->listen(c);
- if (ok == -1) {
+ nc := dial->listen(c);
+ if (nc == nil) {
sys->fprint(stderr(), "listen: listen error on '%s': %r\n", addr);
- listench <-= (-1, nc);
+ listench <-= nc;
exit;
}
if (verbose)
@@ -200,13 +205,13 @@ listener(listench: chan of (int, Sys->Connection), c: Sys->Connection, addr: str
else{
if(nc.cfd != nil)
sys->fprint(nc.cfd, "keepalive");
- listench <-= (ok, nc);
+ listench <-= nc;
}
}
}
-authenticator(authch: chan of (string, Sys->Connection),
- c: Sys->Connection, algs: list of string, addr: string)
+authenticator(authch: chan of (string, ref Dial->Connection),
+ c: ref Dial->Connection, algs: list of string, addr: string)
{
err: string;
(c.dfd, err) = auth->server(algs, serverkey, c.dfd, 0);