AzKay Posted January 10, 2007 Share Posted January 10, 2007 Yes, ive searched, Yes, Ive found scripts. But no, I havnt been able to figure out how to mod one into a function. For example, pretty much all the scripts ive tryed would run once, send one file, exit. What Im wanting is, a function, eg: TCPSendFile($Socket, $File) Something along those lines. Any ideas? # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
AzKay Posted January 10, 2007 Author Share Posted January 10, 2007 Personally, Im in favor of the last suggestion, But ive been here long enough to know that that isnt going to happen. Guess more study time for me. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 10, 2007 Share Posted January 10, 2007 (edited) I would suggest that the client and server have a dedicated port for just sending and receiving files. That makes life a whole lot easier. In addition, when you send a file, you read the file in chunks and then perform a while loop that will send the data via TCP send in chunks of 10240 bytes(10KB packets). That worked pretty well for me at least. Also, if the file is less than 10KB, then simply send the whole file in one packet and then close the connection. The first packet you send when you connect should contain the name of the file and the size of the file in bytes, that way the client knows what the heck the file is and when to stop receiving data because it has received the whole file. I wrote one a while back for a chat program i made, but it isn't clean code, so i am not going to post it and you will learn better if you do it yourself anyway. Don't bother with error correction, TCP protocol has error correction built in, UDP doesn't, so unless you plan to use UDP you don't need to write error correction code into the script that checks for errors when the data is transported. -The Kandie Man Edited January 10, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
automationexpert12345 Posted March 22, 2007 Share Posted March 22, 2007 (edited) I have an application (split into both a client and server module) that uses UDP to provide notification of an incoming data manipulation request to the server. Once this manipulation has completed, I would like the server to send back a .CSV file to the client and store that in a directory of the client's choosing. (Ideally, using TCP). How would this work, especially considering the ports have been forwarded at the router level to access the server from the client, but not vice-versa.In my mind, here are the ways I can accomplish this:1. Send the small .CSV file (but won't always be small) via _SMTPEmail() *** Would work but isn't the most practical way -- I would like to complete the circuit within the application, and not involve e-mail.2. Transfer the file to an FTP site *** Would work, but again, not the most practical way and involves another step.3. Upload to an apache server *** Would work, but again, not the most practical way and involves another step.So, is there anyone out there with experience in both receiving data at the server, and then sending a file back to the client? After looking through dozens of posts on the forums here, I've only come across articles where the client is sending to the server, and not vice-versa.Thanks very much for your time and assistance.- JonI would suggest that the client and server have a dedicated port for just sending and receiving files. That makes life a whole lot easier. In addition, when you send a file, you read the file in chunks and then perform a while loop that will send the data via TCP send in chunks of 10240 bytes(10KB packets). That worked pretty well for me at least. Also, if the file is less than 10KB, then simply send the whole file in one packet and then close the connection. The first packet you send when you connect should contain the name of the file and the size of the file in bytes, that way the client knows what the heck the file is and when to stop receiving data because it has received the whole file. I wrote one a while back for a chat program i made, but it isn't clean code, so i am not going to post it and you will learn better if you do it yourself anyway.Don't bother with error correction, TCP protocol has error correction built in, UDP doesn't, so unless you plan to use UDP you don't need to write error correction code into the script that checks for errors when the data is transported.-The Kandie Man Edited March 22, 2007 by dgdx27c Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now