Final Proxy Code
From
Drakmir@VERT/HDONE to
Digital Man on Fri Oct 7 01:34:00 2005
load("sbbsdefs.js"); // CON_RAW_INãload("sockdefs.js"); // SO_RCVBUFããfunction sendData(socketA, socketB)ã{ã var bRetVal = false;ã var buf;ã ã if(socketA.data_waiting)ã {ã var numRead = socketA.nread;ã if (numRead >= 512) numRead = 512;ã buf = socketA.peek(numRead);ãã if (numRead != buf.length)ã {ã while(numRead > 4)ã {ã buf = socketA.recvBin(4);ã socketB.sendBin(buf, 4);ã numRead -= 4;ã }ã ã if (numRead > 0)ã {ã buf = socketA.recvBin(numRead);ã socketB.sendBin(buf, numRead);ã }ã }ã elseã {ã buf = socketA.read(numRead);ã socketB.write(buf);ã }ã ã bRetVal = true;ã }ã ã return bRetVal;ã}ããtryã{ã if (argc < 2)ã {ã throw("No parameters passed.");ã };ãã var socket = new Socket();ã ã if(!socket.bind()) {ã throw("!bind error " + socket.last_error + "\r\n");ã exit();ã }ã ã var addr=argv[0];ã var port=argv[1];ã ã if(!socket.connect(addr,port)) {ã throw("!connect error " + socket.last_error + "\r\n");ã exit();ã }ã log("\r\nConnected to " + addr + ":" + port + "\r\n");ã ã while(socket.is_connected && client.socket.is_connected) ã {ã if (sendData(socket, client.socket)) continue;ã if (sendData(client.socket, socket)) continue;ã sleep(1);ã }ã ã log("\r\nEnd of socktest!\r\n");ã}ãcatch(E)ã{ã log("Caught error - " + E);ã exit(-1);ã}ããexit(0);ãã---ã þ Synchronet þ Holodeck One - bbs.holodeckone.comã