Subj : Proxy Service Issues
To : All
From : Drakmir
Date : Fri Oct 07 2005 09:56 am
Re: Proxy Service Issues
By: Drakmir to All on Thu Oct 06 2005 08:44 am
So, after working on it last night and with some hints from Digital Man, I've
come up with something that seems to work to proxy a socket. There is only one
unknown, and I've noticed that the use of "sendBin" seems to be what is
crashing my computer. (If I use any number of bytes other that 4 it seems to
occasionaly crash).
The one sticky point is that when using "peek" or "read", sometimes you get a
string that is shorter than the number of bytes available to you. The only
thing I can think of is that there is a embedded \0 character in the data
stream which C is then reading as the end of the string. It would help to have
a read/write that dealt with the "string" we provide as a buffer instead. I
assume this is true because doing:
socket.send("test\0test2"); only outputs "test".
Alan
-+- Code ---
load("sockdefs.js");
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)
{
numRead = buf.length;
buf = socketA.recv(numRead + 1); // Not sure what we are
skipping here, but it seems harmless? Maybe a zero?
socketB.send(buf);
}
else
{
buf = socketA.recv(numRead);
socketB.send(buf);
}