|
Post by crazynate on May 21, 2009 21:22:22 GMT -5
i am planning on making a file sharing program without the use of plugins. Is anyone interested in helping making the client and server file? i already know how to copy files using basic4gl, it's just a matter of networking it.
|
|
|
Post by matthew on May 22, 2009 17:07:14 GMT -5
I'd like to help but currently I'm messing about on something else. It's a shame that nicky & madcow aren't using the forum more regularly as they were good at using the networking commands.
|
|
|
Post by James :) (aka Madcow) on May 22, 2009 18:05:27 GMT -5
Yeah Hopefully i shall be on a bit more after my exams are over. But I might have a go at this EDIT: so far i've got this which works, but i shall comment it if you like and tidy it up later but i have to go atm dim mode dim Connected = false dim file$ Dim Connection input "0 = Server 1 = Client"; mode if mode = 0 then Dim Server = newserver(8000) input "Enter File to Open"; file$ printr "Waiting for Connection..." else input "Enter FileName to SaveAs"; file$ Connection = newconnection("localhost",8000) printr "Connecting to Server..." endif while not Connected if mode=0 then if ConnectionPending (server) then Connection = AcceptConnection (server) Connected = true endif else if not ConnectionHandshaking (connection) then Connected = true endif endif Wend print "Connected!" if mode = 0 then Dim file = openfileread(file$) dim totalbytes printr "Reading Bytes:" while not endoffile(file) totalbytes = totalbytes + 1 print readbyte(file)+"|" wend closefile(file) printr printr "Sending "+totalbytes+" bytes :" dim msg msg = SendMessage (connection, false, false, false) ' Create a message to send down connection WriteInt (msg, totalbytes) ' Write some text CloseFile (msg) sleep(1) while not MessagePending (connection) : wend ReceiveMessage(connection) file = openfileread(file$) dim byte while not endoffile(file) msg = SendMessage (connection, false, false, false) byte = readbyte(file) print byte+"|" WriteInt (msg, 0) Writebyte (msg, byte) CloseFile (msg) sleep(1) wend closefile(file) sleep(1) printr printr "Sending End of File Signal" msg = SendMessage (connection, false, false, false) WriteInt (msg, 1) CloseFile (msg) printr "File Sent" else while not MessagePending (connection) : wend dim msg = ReceiveMessage(connection) dim totalbytes = readint(msg) closefile(msg) printr totalbytes+" Bytes to be sent" printr "Sending OK Status to Server" msg = SendMessage (connection, false, false, false) ' Create a message to send down connection Writeline (msg, "ready") ' Write some text CloseFile (msg) printr "Waiting for server" while not MessagePending (connection) : wend printr "Reciving Bytes:" dim file = openfilewrite(file$) dim byte dim fin = false while connectionconnected(connection) and not fin if MessagePending (connection) then msg = ReceiveMessage(connection) fin = readint(msg) if not fin then byte = readbyte(msg) print byte+"|" writebyte(file, byte) endif closefile(msg) endif wend closefile(file) printr printr "File Recived" endif while true: if scankeydown(vk_return) then end endif:wend
|
|
|
Post by crazynate on May 22, 2009 21:43:38 GMT -5
how many bytes go into a megabyte and a gigabyte im not good with conversions
|
|
|
Post by matthew on May 22, 2009 21:57:18 GMT -5
It's pretty simple to work out if you've got a Scientific calculator nearby... 1 KB = 2 10 = 1,024 bytes 1 MB = 2 20 = 1,048,576 bytes 1 GB = 2 30 = 1,073,741,824 bytes There's an online conversion calculator here.
|
|
|
Post by crazynate on May 22, 2009 23:19:10 GMT -5
Thanks Matthew I needed those numbers because i was going to make the main server run on my computer and i am thinking about setting up the program to have a byte limit so the client users dont bog down my computer with all of their files. Does 100 MB sound like a good limit And a big thanks to you Madcow for helping with the coding. I am not going to use your exact code, because i plan on adding graphics and menus and such I believe i might use the toolbox plugin that djlinux made because it has a function to browse directories !!! my 100th post on this forum !!!
|
|
|
Post by James :) (aka Madcow) on May 23, 2009 5:46:31 GMT -5
No problem, yeah i thought you would i just wrote a basic file sharing program for you to base yours off.
you could also probably make it more efficient at higher sized files too.
|
|
|
Post by DJLinux on May 23, 2009 10:42:18 GMT -5
1KB = 1024 Bytes 1MB = 1024 KB (1024*1024) 1GB = 1024 MB (1024*1024*1024)
By the way you can't use B4GL network to make a public file sharing system. how you will get the IP from other running PeerToPeer client's? (you must use a plugin)
Joshy
|
|
|
Post by UNDISCLOSED on May 23, 2009 11:55:03 GMT -5
I Think the idea is that it is only for sharing beetween itself, and also only people you want to share with.
|
|
|
Post by DJLinux on May 23, 2009 12:22:49 GMT -5
I Think the idea is that it is only for sharing beetween itself, and also only people you want to share with. how would get the people you want to share with the IP for a new connection? (the problem is the same for public and private network connections) Joshy
|
|
|
Post by UNDISCLOSED on May 23, 2009 15:00:27 GMT -5
If you open command prompt and type ipconfig, it gives you your IP adress, and then the people wanting to share files can tell each other thier IP adress and then they can start a connection. and then you could create a system where you can save peoples names so you can just select thier name instead of trying to remember thier IP Adress.
|
|
|
Post by crazynate on May 23, 2009 16:02:09 GMT -5
I think you both have it wrong. i was going to make 1 server program and distribute the client program that way there's only 1 ip to connect to
|
|
|
Post by UNDISCLOSED on May 24, 2009 2:29:27 GMT -5
Ahhh.... That makes much more sense. I guse you will need a server to run the server program on tho (Not that I have one).
|
|
|
Post by Darkjester on May 24, 2009 14:05:53 GMT -5
one prob networking requires you know the IP address of both ends of the connection otherwise nothing will work, secondly how many people are actually going to want to open up a command prompt just to get their IP address? Djlinux i know this is out of thread but sense its part of this discussion how would you go about returning the persons IP address from their computer using a plugin? Perhaps reading the registry or something else?
|
|
|
Post by crazynate on May 24, 2009 14:21:43 GMT -5
i remember seeing a basic4gl program that retrieves the ip
|
|