-
Socket Test
From
MCMLXXIX@VERT/MDJ to
Deuce on Tue Apr 29 18:47:02 2008
Ok, so I messed with the code you sent me a little, and tried it using ãboth "127.0.0.1" with port 5000 + bbs.node_numãand "127.0.0." + bbs.node_num with port 5000ããboth had the same result, listen error: 45ãbut there didn't seem to be a problem binding them either wayããhere's the code.. it's spammyãI didn't really expect it to work, since I'm half guessing, but I thought I ãwas on the right track.. maybe not.ããload("sockdefs.js");ãload("sbbsdefs.js");ãload("nodedefs.js");ããvar stream=new Socket(SOCK_DGRAM, "InterNode");ãmain();ã ãfunction main()ã{ã if(!stream.bind(9000+bbs.node_num, "127.0.0.1")) {ã writeln("Bind failed: "+stream.error);ã exit(1);ã }ã else ã {ã if(ConnectionListener()) Chat();ã else exit(1); ã }ã}ãfunction Chat()ã{ã //Receive();ã writeln("Test connection successful");ã exit(0);ã}ãfunction ConnectionListener()ã{ã write("Waiting for users to connect");ã for(i=0;i<10;i++)ã {ã for(node in system.node_list) {ã stream.sendto("ping","127.0.0.1",9000 + node);ã }ã if(stream.listen()) return true;ã if(console.inkey().toUpperCase()=="Q") exit(1);ã
mswait(250);ã write("."); ã }ã writeln("\r\nListen failed: "+stream.error);ã exit(1);ã}ãã---ã þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)ã
-
From
Deuce@VERT/SYNCNIX to
MCMLXXIX on Tue Apr 29 19:35:59 2008
Re: Socket Testã By: MCMLXXIX to Deuce on Tue Apr 29 2008 06:47 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.ãã--- ãSynchronet - Jump on the Web 0.2 bandwagon!ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
-
From
Deuce@VERT/SYNCNIX to
MCMLXXIX on Tue Apr 29 20:24:57 2008
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!)ã
-
From
MCMLXXIX@VERT/MDJ to
Deuce on Wed Apr 30 08:35:32 2008
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.ããIs there a way to tell if there is anyone on the receiving end? I.E. if you're ãthe only one trying to run the engine it will either wait for someone to ãconnect, or kick you out. I guess I can make it send a "yo! I'm here!" message ãwhen anyone runs it.ãã---ã þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)ã
-
From
Deuce@VERT/SYNCNIX to
MCMLXXIX on Wed Apr 30 11:08:54 2008
Re: Re: Socket Testã By: MCMLXXIX to Deuce on Wed Apr 30 2008 08:35 amãã > Is there a way to tell if there is anyone on the receiving end? I.E. ifã > you're the only one trying to run the engine it will either wait forã > someone to connect, or kick you out. I guess I can make it send a "yo! I'mã > here!" message when anyone runs it.ããNot with UDP... with TCP this is possible.ãã--- ãSynchronet - Jump on the Web 0.2 bandwagon!ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã