🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

File Sharing Information

Started by
8 comments, last by Tszafran 22 years, 8 months ago
Hi, Im gonna start to program a file sharing application. It won''t be the next Napster, etc its a learning experiance. I was wondering if anyone can point me in a direction for more psuedo code or explanations of how the internals of a system like this work. I understand some the basics, but some things like storing the file-lists in the database, and searching it still need some clearing up. About databases, what should I use? SQL? ADO? DAO? I would need it to access the database multiply times within seconds. This is what I got so far, correct me if I am wrong... The client sends it login info to the server, the server changes the information into the database so the user is considered online and the file list is updated. From there the user can send searches which the server looks into the databases and sends the results back to the client from which the client chooses files to download which happens in Peer 2 Peer connections not requiring the server. Also the server sends connection checks/pings to the clients to make sure they are still online. Thanks in advance for your help. Thomas Szafran
MSN Messenger: Thomas_Szafran@hotmail.com
Advertisement
One quick clarification for you:

ADO/DAO are not databases in themselves. They are the APIs you use to access a database. ADO is definitely the way to go when accessing large databases.



Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
Thanks for the information about the databases, I knew that about databases but didnt word it correctly. Once again thanks for the ADO suggestion, I was trying to find the differences between DAO and ADO to select which one to use.
MSN Messenger: Thomas_Szafran@hotmail.com
Hiya,

I never used napster my self but i have used the Gnutella network. There are many clients for the Gnutella network all which use the Gnutella protocal to connect together. There is no centralised server, its all done on peer 2 peer ;-) there are servers which log the IPs of peers so that new peers can grab a list of recent peers on the network.

one great site which provides design info and source is
http://core.limewire.org/
I even found a nice design page for ya ;-)
http://core.limewire.org/project/www/design.html

Good luck
~Tim
~ Tim
Well, have you decided whether you want a centralized server system or a peer-to-peer system? You mention both... unless you are coming up with some new hybrid system we haven''t seen yet, I think you need to make a decision first. I think you''ve got the basic ideas down, you just need to start coding!

I wouldn''t think a dedicated database would be necessary at all in a peer-to-peer system. However, I also think such a system is harder to architect and manage.

Take a look at MySQL.org for a free SQL-based relational database system. You could also use Access if you own a copy.
Thanks again those are some excellent sites and I guess coding should now start. Also sorry if my ideas were not clear, I meant to have a central server which clients search from, then the downloads happen peer to peer from eachother. Total peer to peer network at this stage would be over my head.
MSN Messenger: Thomas_Szafran@hotmail.com
Good luck..

just before you run off and code is a great idea to fully design it at least the protocal .. so sit down and write a list of everything that the client will say to the server and the server to the client and possibly think about how the server then tells the client to connect to another client and how they comunicate ;-) I when thats all written down the programming is relativly easy.. otherwise you end up hacking it and then changing it 100 times and you end up giving up :-p

~tim
~ Tim
Thats a good idea, currently I am programming the database functions and just testing them out. One thing I dont understand is how do the users update their file list. Im having trouble explaining this but I mean how should the files list be put into the tables field? Should it be a continues string of filenames into the field? or do I upload a file with all the filesnames and sizes into the field somehow? Any help would be appreciated.
MSN Messenger: Thomas_Szafran@hotmail.com
ok..
not sure if your confused about how to structure your table or how to send the users list of files or both so ill talk about both...

Database structure .. hmmm this is what i think so that its "fully normalised" ie no repeated data

User table
UserID (Auto Inc unique Number)
IP (String.. or to save more space could be a 32 bit integer.. but if you dont know how you would do that just use a string)
Port (Int .. it wiould be usefull for clients to specify their own port that they serve from)
Speed (int ... as a possiblity .. not required ;-) )

Files table
FileID (Auto Inc unique Number)
UserID (Int .. References a user in the user table)
FileName (String)
FileSize (Int)


ok.. When a userX connectes..
Server creates a new entry in Users table for the connected user
Server sends a message asking for the clients file list
UserX sends the file list... its up to you what format the client sends their list .. here is an example how:
Byte(Length(filename1)) + filename1 + 4ByteInteger(FileSize1) + Byte(Length(filename2)) + filename2 + 4ByteInteger(FileSize2) + ... + Char(0)
notes :
* in this case the file names can be a max of 255 characters long because im using a Byte for the length
* When you read the length of the next filename and it = 0 then you have finished all the reading
* Store each new file in a new entry in the Files table using the UserID for that client

When the clients disconnects
Delete all the file entries with a matching UserID
Delete the User with the matching UserID

easy as that lol ;-)

hope that helps.. and remember there is always more than one way to do something

~Tim
~ Tim
That''s not quite fully normalized, since there could be a number of users with the same file (which will happen once people start sharing!)

Perhaps another table design would be:

UserTable:
UserID (primary key)
Name, etc...

UserList:
FileID (foriegn key into FileList.FileID)
UserID (foriegn key into UserTable.UserID)

FileList:
FileID (primary key)
FileName, etc...

That way, for every file that''s the same, you can have just one FileList entry and you only remove the FileList entry when there''s no more users that have that file online. The advantage with this method is that if you''re downloading a file and the user you''re getting it from goes offline, you can just switch users. Also, if you have a fast connection, you can download it from two different users at the same time. Obviously the disadvantage is the extra overhead and programming complexity.

Finally, beware storing the IP as an integer, because that''s not IPv6 aware. I think if you''re making a new internet app, you should be awate of IPv6 - especially since Windows XP now supports it.

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement