Subj : Proxy Service Issues
To : All
From : Drakmir
Date : Thu Oct 06 2005 09:44 am
I am trying to write a simple socket proxy in Synchronet's Javascript language,
and having a very hard time of it. The code below is my latest attempt, but
I've tried many variations on that theme (including blocking sockets, using
send/receive buffers, etc).
All of them either result in a crash in the services module or a lockup of all
networking (including non synchronet) on the computer. I'm running with
Synchronet 3.12 and on Win2k.
Can someone assist with this and tell me what I'm doing wrong?
Thanks!
Code follows.
Alan Wood
----- CODE ------
load("sockdefs.js");
function CopyData(socketA, socketB)
{
if (socketA.poll())
{
if (socketB.poll(0, true))
{
var nBytes = socketA.nread;
var readVal = socketA.recvBin(1);
if ((readVal > 0) && (socketA.error == 0))
{
if (!socketB.sendBin(readVal, 1))
{
throw ("Error writing to socket");
}
}
}
}
}