I am trying to write a simple socket proxy in Synchronet's Javascript langua 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 a networking (including non synchronet) on the computer. I'm running with Synchronet 3.12 and on Win2k.
Re: Proxy Service IssuesSo, I adapted socktest to read from client.socket instead of console, and for some reason it won't read the input. I basically just changed the RAW mode inkey for the same if logic above (client.socket.data_waiting).
By: Digital Man to Drakmir on Thu Oct 06 2005 07:44 pm
I hadn't seen that one. I'll take a look at it and see if it works for my application. :)
That proxy is slow because I removed block read/write since I wasn't sure wh was going wrong. It was the simpliest example I could get to fail and not t down the computer with it.
Thanks again!
Alan
Re: Proxy Service IssuesThe following code has the issue above (no read of the client socket for some reason):
By: Drakmir to Digital Man on Thu Oct 06 2005 11:25 pm
Re: Proxy Service Issues
By: Digital Man to Drakmir on Thu Oct 06 2005 07:44 pm
I hadn't seen that one. I'll take a look at it and see if it works for m application. :)
That proxy is slow because I removed block read/write since I wasn't sure was going wrong. It was the simpliest example I could get to fail and no down the computer with it.
Thanks again!
AlanSo, I adapted socktest to read from client.socket instead of console, and fo some reason it won't read the input. I basically just changed the RAW mode inkey for the same if logic above (client.socket.data_waiting).
Is there a socket option that has to be set or something?
Alan
Re: Proxy Service Issues
By: Drakmir to Digital Man on Thu Oct 06 2005 11:25 pm
Re: Proxy Service Issues
By: Digital Man to Drakmir on Thu Oct 06 2005 07:44 pm
I hadn't seen that one. I'll take a look at it and see if it works for m application. :)
That proxy is slow because I removed block read/write since I wasn't sure was going wrong. It was the simpliest example I could get to fail and no down the computer with it.
Thanks again!
So, I adapted socktest to read from client.socket instead of console, and fo some reason it won't read the input. I basically just changed the RAW mode inkey for the same if logic above (client.socket.data_waiting).
Is there a socket option that has to be set or something?
Re: Proxy Service Issues
By: Drakmir to Digital Man on Fri Oct 07 2005 12:38 am
Re: Proxy Service Issues
By: Drakmir to Digital Man on Thu Oct 06 2005 11:25 pm
Re: Proxy Service Issues
By: Digital Man to Drakmir on Thu Oct 06 2005 07:44 pm
I hadn't seen that one. I'll take a look at it and see if it works fo application. :)
That proxy is slow because I removed block read/write since I wasn't s was going wrong. It was the simpliest example I could get to fail and down the computer with it.
Thanks again!
So, I adapted socktest to read from client.socket instead of console, and some reason it won't read the input. I basically just changed the RAW mo inkey for the same if logic above (client.socket.data_waiting).
Is there a socket option that has to be set or something?
Yes, you can't perform I/O on the client's socket descriptor while the BBS's input thread is servicing the socking. You must set console.lock_input to tr before accessing the client's socket directly and set it to to false when you're done.
digital man
Snapple "Real Fact" #12:
Emus and Kangaroos cannot walk backwards.
Re: Proxy Service Issues
By: Digital Man to Drakmir on Thu Oct 06 2005 11:27 pm
Re: Proxy Service Issues
By: Drakmir to Digital Man on Fri Oct 07 2005 12:38 am
Re: Proxy Service Issues
By: Drakmir to Digital Man on Thu Oct 06 2005 11:25 pm
Re: Proxy Service Issues
By: Digital Man to Drakmir on Thu Oct 06 2005 07:44 pm
I hadn't seen that one. I'll take a look at it and see if it works application. :)
That proxy is slow because I removed block read/write since I wasn' was going wrong. It was the simpliest example I could get to fail down the computer with it.
Thanks again!
So, I adapted socktest to read from client.socket instead of console, some reason it won't read the input. I basically just changed the RAW inkey for the same if logic above (client.socket.data_waiting).
Is there a socket option that has to be set or something?
Yes, you can't perform I/O on the client's socket descriptor while the BB input thread is servicing the socking. You must set console.lock_input to before accessing the client's socket directly and set it to to false when you're done.
The problem with that is when you have a "service", the console object doesn exist.
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'v come up with something that seems to work to proxy a socket. There is only o 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 t occasionaly crash).
The one sticky point is that when using "peek" or "read", sometimes you get 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 h 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".
Re: Proxy Service Issues
By: Drakmir to All on 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, come up with something that seems to work to proxy a socket. There is onl 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 seem occasionaly crash).
What value (for number of byte) did you use when it crashed? Do you have example code that can reproduce this crash?
The one sticky point is that when using "peek" or "read", sometimes you g string that is shorter than the number of bytes available to you. The on 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 t a read/write that dealt with the "string" we provide as a buffer instead. assume this is true because doing:
socket.send("test\0test2"); only outputs "test".
Ah, true. That'll be fixed for the next release. :-)
digital man
Snapple "Real Fact" #8:
A bee has 5 eyes.
Sysop: | Clippy |
---|---|
Location: | Houston, TX |
Users: | 4 |
Nodes: | 4 (0 / 4) |
Uptime: | 215:11:11 |
Calls: | 1 |
Files: | 11 |
Messages: | 38,209 |