Subj : Queues vs. Sockets
To   : MCMLXXIX
From : Deuce
Date : Tue Apr 29 2008 01:07 am

 Re: Queues vs. Sockets
 By: Deuce to MCMLXXIX on Tue Apr 29 2008 12:36 am

> Yes, you have one node bind/listen on a port and another node connect to
> it. But it sounds like what you want is many nodes connected to many other
> nodes. If reliability isn't needed AND it doesn't need to work on
> multisystem installs, slicing off a part of the localnet and using
> broadcase would most likely be easiest.  Basically, have each node bind to
> a known port on 127.0.0.X where X is the node number.  I think XP has an
> issue with this though... see:
> http://support.microsoft.com/default.aspx?scid=kb;[LN];884020
>
> I'll see what I can whip up quickly for an example...

load("sbbsdefs.js");
load("sockdefs.js");

var s=new Socket(SOCK_DGRAM, "InterNode");
if(!s.bind(5000, "127.0.0."+bbs.node_num)) {
       writeln("Bind failed: "+s.error);
       exit(1);
}
if(!s.listen()) {
       writeln("Listen failed: "+s.error);
       exit(1);
}
writeln("Q to quit or # to send message to node");

while(1) {
       var k=console.getkey(K_NONE, 100);
       if(k.toUpperCase()=='Q')
               break;
       if(parseInt(k) > 0) {
               console.write(": ");
               var msg=console.getstr("", 77);
               s.sendto(msg,"127.0.0."+k, 5000);
       }
       if(s.data_waiting) {
               var d;
               d=s.recvfrom();
               writeln("Message from "+d.ip_address);
               writeln(d.data);
               writeln("");
       }
       writeln("Loop!");
}


This does NOT work under FreeBSD since you cannot actually listen on any
loopback address except 127.0.0.1... not sure of other OSs.  Failing that, you
can use port number X+bbs.node_num and just not be able to broadcast... which
may be enough.  Fiddle with the 5000 instead of 127.0.0. in the script.

TCP gets trickier.  :-)

---
Synchronet - Jump on the Web 0.2 bandwagon!

---
� Synchronet � My Brand-New BBS (All the cool SysOps run STOCK!)