Subj : Socket Test To : MCMLXXIX From : Deuce Date : Tue Apr 29 2008 08:24 pm Re: Socket Test By: Deuce to MCMLXXIX on Tue Apr 29 2008 07:35 pm > > both had the same result, listen error: 45 > > but there didn't seem to be a problem binding them either way > > Heh, whoops, mixing my protocols there. You don't listen() for UDP since > it's connectionless. > > Remove the listen() call and all should be good. Here's the code updated to do it both ways: load("sbbsdefs.js"); load("sockdefs.js"); var base_port=5000; var use_ports=true; var s=new Socket(SOCK_DGRAM, "InterNode"); var bind_addr="127.0.0."; var bind_port=base_port; if(use_ports) { bind_addr += "1"; bind_port += bbs.node_num - 1; } else { bind_addr += bbs.node_num; } if(!s.bind(bind_port, bind_addr)) { writeln("Bind to "+bind_addr+":"+bind_port+" failed: "+s.error); exit(1); } writeln("Q to quit or # to send message to node"); while(1) { var k=console.inkey(100); if(k.toUpperCase()=='Q') break; if(parseInt(k)>0) { console.write(": "); var msg=console.getstr("", 77); var port=base_port; var addr="127.0.0."; if(use_ports) { port += parseInt(k)-1; addr += '1'; } else { addr += k; } s.sendto(msg, addr, port); } if(s.data_waiting) { var d; d=s.recvfrom(); writeln("Message from "+d.ip_address+":"+d.port); writeln(d.data); writeln(""); } } --- Synchronet - Jump on the Web 0.2 bandwagon! --- þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!) .