Jump to content


Photo

39dll File Transfer Script Problems


  • Please log in to reply
2 replies to this topic

#1 theshadowmoose

theshadowmoose

    GMC Member

  • New Member
  • 57 posts

Posted 20 August 2009 - 03:32 PM

Hmm, well. I recently decided to see if I could make a file tranfer script (Using methods mentioned in other posts). However, I have hit a snag. Either the scripts I made, or the way that I use them somehow doesn't work. The script that sends the file appears to work, but the script that recieves the file doesn't even make an empty file like it should if it got any data at all. These scripts aren't vital to me, but I would appreciate it if someone could look at my example (or just the scripts), and tell me if they see whats wrong. It is true that I havent really learned about 39dll before, and these two scripts are my first attempt at file transfer. Thanks for your time!

-TheShadowMoose (TSM)
Here are the scripts (Below them is the download for how I use them):
SENDING -- NOTE: When I created this one, I tested it by reading each ds_list value to the buffer, writing it to a file, then clearing the list. That worked perfectly.
//0 -- socket to send over
//CALL ONLY ONCE!
var pos, chunk,i,f;
tcp=argument0
pos = 0
chunk = 1000
global.list = ds_list_create()
i = 0
f=fileopen(get_open_filename("All Files *|*",""),2)
//-------------------------------------------------------------------------------
setformat(tcp,2)
while(pos <filesize(f))
{
	filesetpos(f,pos);
	ds_list_add(global.list,fileread(f,chunk))
	pos+=chunk
}
fileclose(f)
show_message("BUFFERED ALL THE DATA...SENDING...")
///loop ends
//now for sending it...
for(i=0;i<=ds_list_size(global.list);i+=1)
{
	writechars(ds_list_find_value(global.list,i))//writes to buffer
	sendmessage(tcp)//sends it.
	clearbuffer()//clears le buffer
}
show_message("SENT!!!")

RECIEVING
//0 -- socket to listen on
//1 -- name to save as.
//CALL IN STEP/DRAW
var tcp,f,s;
tcp=argument0
setformat(tcp,2)//sets the format.
f=fileopen(argument0,2)
//remember to close it!!!!!

while(receivemessage(tcp) >0)
{
	filewrite(f)
}

fileclose(f)

And HERE -- .zip contains 2 game maker files, and 39dll
Thanks!

Edited by theshadowmoose, 20 August 2009 - 10:41 PM.

  • 0

#2 mcf1lmnfs

mcf1lmnfs

    GMC Member

  • New Member
  • 14 posts
  • Version:GM8

Posted 09 November 2011 - 06:34 PM

in reciving program, it would probably help if you were actually trying to read the chars recived... readchar()

you cant write something you didnt read, at least in programs =)

Edited by mcf1lmnfs, 09 November 2011 - 06:34 PM.

  • 0

#3 39ster

39ster

    GMC Member

  • GMC Member
  • 898 posts

Posted 13 November 2011 - 09:02 AM

in reciving program, it would probably help if you were actually trying to read the chars recived... readchar()

you cant write something you didnt read, at least in programs =)


Is the socket blocking or non blocking? If it's blocking then there shouldn't be a problem with the sending stuff. If it's non-blocking, and you try to send a big file, you're going to have problems. Imagine sending a 4GB file on a non-blocking socket. In the script logic, it would seem the file was sent instantly (as it does not block), but we know that isn't possible. You need to check the result of sendmessage(). If there is already too much data being sent, sendmessage() will return an error.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users