Computer Science Canada

Net commands - At it again.. need help :)

Author:  LaZ3R [ Thu Jun 21, 2007 10:55 pm ]
Post subject:  Net commands - At it again.. need help :)

I just want to know if there's any way I can get turing to freaking send data over the net structure at faster rate.
I've created a file transfer program and I have it working pretty well so far, only problem being that it goes at a rate of about 1-2 kb/s which is pathetic. Is there any way I can speed the rate up?

1000-2000 bytes per second isn't cutting it Sad.

Author:  Saad [ Fri Jun 22, 2007 9:55 am ]
Post subject:  Re: Net commands - At it again.. need help :)

Turings net command is really slow and not reliable. Which is its limit (quite sure)

Author:  Dan [ Fri Jun 22, 2007 1:57 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

It could also be your code, but unless you post it, we will be unable to help much.

As for file tranfser, you may have some problems with binnary file transfer as turing dose not like some cahrs like the null char chr(0). It is very likey that some files will have this char and causes it to crash or corput the file.

Author:  LaZ3R [ Sat Jun 23, 2007 12:00 am ]
Post subject:  Re: Net commands - At it again.. need help :)

I was so determined to get this working faster, and guess what, I did Smile

I edited a bit of code, and maybe added 2-3 lines extra and now it uploads/downloads at around 60-65kb/s, tested this with a friend across the net, so I'm happy Smile

Tiem to get conversion working so I can send zip's and all other kinds of files Smile.

Author:  Tony [ Sat Jun 23, 2007 4:00 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

Would be great if you were to share as to how you got such an improvement in data transfer with Turing.

Author:  LaZ3R [ Sat Jun 23, 2007 10:02 pm ]
Post subject:  Re: Net commands - At it again.. need help :)

Ok, well, I figured that Turing can only handle 255 chars per string at a time. So my program reads a text file (for now only text files), gets 255 characters and stores it into an array of string. I created 200 arrays of string so using a for loop, I end up putting 200 variables of string each containing 51,000 bytes of data each time (51kb). The client then has a for loop which gets all 200 blocks of data and stores it into the file as it's supposed to Smile, and this process continues over and over until all the data is transfered.

If I have time, I'll make a mini-tut on this, but it's really simple. Instead of only putting 1 variable into the netStream each time, put tons Smile

It's not the most practical way of sending data over a net connection, but I really didn't see much other option when thinking of this idea lol. I'm trying to also figure out why Turing has a problem sending 300 variables of string over the netStream as opposed to 200 which I use now with no problem. My guess is maybe 255 is a special number where Turing doesn't like anything more than that :p.

I'll keep updating on this in case anyone cares, net commands are still not my exact best area of Turing right now but I'm trying to improve as always Smile

Author:  Saad [ Sun Jun 24, 2007 9:29 am ]
Post subject:  Re: Net commands - At it again.. need help :)

Last time i tried sending more then 1 variable into the stream data would get lost. Also turing doesnt send it all at the same time. Sometimes i've recieved data fromt he stream that i sent later come before the data i had sent earlier. I wouldnt recommend sending 10+ Variables in the net stream unless you have a way to check the order it is sent and recieved as data gets messed up.


Saad

Author:  LaZ3R [ Sun Jun 24, 2007 10:23 am ]
Post subject:  Re: Net commands - At it again.. need help :)

? Turing gets every variable into a netStream in the exact same order it was put in. What you need to do is simply have the other end send a piece of data over the netStream like in my program which says "go" once all the data has been received. The server is stuck into a loop which waits for the netStream to send the "go" data and upon receiving it, exits the loop and sends the next batch of variables. The reason you might've had a problem sending more than 10 at a time is because you might've been sending them out faster than the client was receiving them and as a result inputted new 1-10's even if the client was still getting 5 or 6 off the netStream.

I really think I'll make a tutorial on file transfer once I get the chance and hopefully this will all make a little more sense Smile.

Author:  LaZ3R [ Sun Jun 24, 2007 9:31 pm ]
Post subject:  Re: Net commands - At it again.. need help :)

Ok, I need help from you guys now. I want to make this file transfer program have the ability to transfer ANY type of file (zip, exe, etc).

Only problem is that some of the char's used in these types of files are not very friendly with Turing.

Example on zip file... I tried to transfer it but the 4th - 6th character's are blank, however only the 1st blank in the set cause turing to crash and give an error "char converted to EOS or uninitchar" (something like that). Also, turing decides that the end of file in the zip is like 15 characters too short cutting off the last bit of it including the file name within the zip and a few other weird ascii char's.

I thought about converting to binary and having the client convert back to ascii but thought it wouldn't solve my problem in this case. Sad Any idea's?? There MUST be a way.

Author:  Decadence666 [ Sun Jun 24, 2007 9:52 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

Yeh. Don't use turing.

K, on a serious note though... You could try Replacing the null characters with something else, like the string "NULL" , and then when the client receives it, it converts it back? Maybe? Who knows.

Author:  LaZ3R [ Sun Jun 24, 2007 10:06 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

Ok, I've fixed the fact that the end of the zip file was being cut off... stupid on my part for putting an early exit condition in the for loop. Razz

I also managed to make it so turing converts the ord of the value into string and it works that way and inputs into the netStream fine... however, the zip file apparently opens up damaged without the file inside when I open it after being sent over the program.

Trying to figure out now what the hell to do, the files are 100% the same to the character when viewing the zip in notepad. Sad

Author:  Dan [ Sun Jun 24, 2007 11:01 pm ]
Post subject:  Re: RE:Net commands - At it again.. need help :)

Dan @ 22nd June 2007, 1:57 pm wrote:

As for file tranfser, you may have some problems with binnary file transfer as turing dose not like some cahrs like the null char chr(0). It is very likey that some files will have this char and causes it to crash or corput the file.


As i perdiected in this qoute turing dose not like some of the chars in non text files. I don't see any good way to over come this becues as soon as the net model gets a char like the null char it will crash or cut it off. If you somehow where able to replace the char with another one or string then it could work (however this may not be posible becues turing will probly not let you read in a file with a null char in it right) but then what happens when you have a file that has the same char or string you used to replaced the null char?

There is a method of using the put function with a speahal kind of char array that whould let this work however there is a bug in it's implemation witch i have talked about befor in other threades that will causes new problems.

The fundementaly problem is with how turing deals with and implments strings and i am not shure if this can be fixed with out using out side programs or recoding turing. If you do find a way please let us know.

Edit: What you are not seeing in your file viwer are the chars that are not printable like the null char and thess are the chars that turing has problems with.

Author:  LaZ3R [ Mon Jun 25, 2007 10:44 am ]
Post subject:  RE:Net commands - At it again.. need help :)

Well I'm obviously at a standstill now. I've tried QUITE a few different methods to try and preserve this null value and send it to the netStream but I'm finding that to be a pain in the ass Sad

For some reason, Turing doesn't have a problem RECOGNIZING these special values, but rather has trouble adding them into string variables of any sort. I'm trying to think what would happen if I sent one char at a time for a test to see if that would work which in that case I have already thought of a solution to not drastically slow down the speed of transfer in the program, I'll definitely make a post if I figure something out soon :p.

Author:  Shyfire [ Mon Jun 25, 2007 12:26 pm ]
Post subject:  Re: Net commands - At it again.. need help :)

ok well u could have turing read the file your sending and if it finds a null char then have it just send that char only then continue normally

Author:  LaZ3R [ Mon Jun 25, 2007 1:57 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

That was my idea Smile

Then I figured out that Null isn't the only character that Turing doesn't like and as a result, simply converting all the data into binary, sending it over the stream, and unconverting it might work slightly better.

I've got my program to fully convert the file into binary and send it in parts to the client, I simply need to make the client convert it back into ASCII and then I can test this out and HOPE TO GOD it works or I'll cry Sad

Author:  LaZ3R [ Mon Jun 25, 2007 2:15 pm ]
Post subject:  Re: Net commands - At it again.. need help :)

var dec, bin : int := 0
var binstr, input : string

dec := input
for decreasing i : 8 .. 0
if (dec - (2 ** i)) >= 0 then
dec := dec - (2 ** i)
bin := bin + (1 * 10 ** i)
end if
end for
binstr := intstr (bin)

--------------------------------

That's what I am using to convert ASCII into binary, but I'm having a problem changing that around so it converts back into ASCII from binary :p. Anyone willing to help with that for me? Sad

(Note: That is NOT what is exactly in the code for my program, it's simply the very basic lone part of it without the strings etc, so don't bother asking about it Razz)

Author:  Saad [ Mon Jun 25, 2007 2:22 pm ]
Post subject:  Re: Net commands - At it again.. need help :)

To convert binary to decimal is very simple


take for example the number 1011 which is = 11. In binary you are base 2 so therefore

1011 = 1*(2^3) + 0 * (2^2) + 1 * (2^1) + 1 * (2^0) = 8 + 0 + 2 + 1 = 11

Author:  LaZ3R [ Mon Jun 25, 2007 6:27 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

UPDATE:

Zip files now transfer easily! Very Happy

Speed of transfer pretty much remains the same. I pretty much did what I initially tried and failed at before attempting to do binary conversion.

My original idea was the exact same thing Shyfire mentioned. I simply made turing cut off where it finds a null character, sends whatever it has got up to, send a seperate char to the netStream which tells the netStream to place a null character in the file right after the previous string. Using this method, I've finally got that damn null out of my way and am now ready to move onto the graphical side of this (along with minor other things I find along the way) Smile

Thanks for the help guys, I'll be back if I need any more Smile

Author:  LaZ3R [ Tue Jun 26, 2007 11:00 pm ]
Post subject:  RE:Net commands - At it again.. need help :)

Bleh, I've finally figured it out. Any file types and filesize's can now be properly sent over the program Smile

Any zips, encrypted zips, exe's, pictures of any kind, text documents, word files, powerpoint, anything Smile

Thanks for the help some of you guys put in Smile, I'm definitely going to keep working on this because it's really helping my mind Smile


: