Doubt about file transfering program

This is a discussion on Doubt about file transfering program within the C Programming forums, part of the General Programming Boards category; I'm trying to program a file sender/receiver for linux, I've done a basic one to send and receive from a ...

  1. #1
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193

    Doubt about file transfering program

    I'm trying to program a file sender/receiver for linux, I've done a basic one to send and receive from a computer to another and I want to go further. I've thought of using a queue, with the files, I'm sending and receiving the files in parts, my idea is to loop the queue sending and receiving until all the files are sent or received, I mean, send, receive and go back again with the same file is there's only one or do the same with the other file. Will that be a good way to do it? I've thought of forking, is it a good idea? dive the receiving and the sending.
    Also, how could I measure the download and upload speed doing queues?
    Thanks in advance

  2. #2
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    Your idea is nice ,

    After completing your simple connection between client and server , you must frame rules for transfering the files , hopefully u cannot transfer a whole file content in a single row, if u r strong enough in the basics u must know the contents transfered via packets , I suggest you to use TCP , since UDP has many problems.

    I also suggest you to use struct type which may contains the file name , contents , part name ( since a whole file can be transferred by separate parts ) , etc.

    It is better to have a queue of these structs , since you can frame many files in a queue,
    Also dont forget to frame some code ( that also a part of the rules which u are framing ). since using this code only u can make the clients ready.
    for ex :
    #define READY 0 // Alert the client
    # defined TFR 1 // Files are transfering
    # defined STRT 2 // start of the file
    # define END 3 // file ends

    some thing like that ,

    After framing all the skeleton enhance your application whatever u want .

    In order to measure your performance and monitor I suggest you to use the "wireshark" tool.
    I also suggest you to not to use the fork , it definitely kill your performance , so please use the "select" .
    combination of "select" and "tcp" will definitely gives you good performance !!!

    ALL THE BEST !

  3. #3
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Are you trying to write your own protocol? There are massive amounts of libraries out there that support various transfer protocols and p2p networking protocols.

    I'm not trying to give you grief for writing something that has already been written, I do it all the time. Just what is your ultimate goal?

  4. #4
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    Thanks Alex and Carrotcake, I'm actually using an struct that stores the parts sended/received, the total parts, the file descriptor and a variable that stores if it has a last part of a different size of what my chunks are or if it has an unique part size less than the size of the common parts.
    About creating my own protocol, it is just a project, it won't be as complex as other protocols, just a simple file communication.
    How about measuring the connection speed?

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by Alexander jack View Post
    I also suggest you to not to use the fork , it definitely kill your performance , so please use the "select" .
    combination of "select" and "tcp" will definitely gives you good performance !!!

    ALL THE BEST !
    select() has very poor performance on Windows. And TCP isn't exactly a "performance" protocol. I would suggest using a "polling" wrapper like libevent.

    Quote Originally Posted by lautarox
    How about measuring the connection speed?
    Just keep track of how many bytes you send, and how many seconds it took. For example, if you sent 1024 bytes in 2 seconds, that's 512 bytes/sec.
    Last edited by zacs7; 02-25-2010 at 12:55 AM.

  6. #6
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    Not at all saying TCP is a performance protocol, u mis understood , I was trying to say TCP is better than the UDP protocol, since if we use UDP definitely a packet lose would be happen at that time user has to write a code to solve that in the case of TCP the protocol itself take the responsiblity of re-send the losed packet,

    Have a used "wireshark"

    Protocol means RULES , you frame your own codes which your client and server only can understand , it must not to be as complex as TCP and UDP or some other protocols.

    I asked you to frame your rules not actually a complete protocol.
    Last edited by Alexander jack; 02-25-2010 at 01:11 AM.

  7. #7
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    Quote Originally Posted by zacs7 View Post
    select() has very poor performance on Windows. And TCP isn't exactly a "performance" protocol. I would suggest using a "polling" wrapper like libevent.
    What do you think about libev? libev it says it has a better performance.

    About my own protocol, yes, I wasn't saying I wasn't creating my own protocol, It's just an small protocol =P.
    I'm using gtkmm for the GUI, let's see what's happen.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-16-2009, 07:00 AM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. counting program worked, but test file CRASHES IT.. WHY?
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2002, 03:29 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21