FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 31st, 2003, 01:11 PM
sai_student sai_student is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 sai_student User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
C language Ftp sending in windows

I want to upload some text file through ftp . how can I done this ???
I'm now using Borland Turbo C and it's have many preprocessor that i don't know what meaning of using it -_-"
(My OS = window)

I'm just a newbie T^T

pls help me out of this problem ToT

sorry I'm very poor in english ^^"

Reply With Quote
  #2  
Old August 31st, 2003, 01:22 PM
movEAX_444's Avatar
movEAX_444 movEAX_444 is offline
Cast down
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Sweden
Posts: 321 movEAX_444 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 56 m 35 sec
Reputation Power: 6
This might help:
http://www.cpp-home.com/tutorial.php?256_1

edit: Looking back at the link, nm it, it sucks, I don't think it's what your looking for.

Last edited by movEAX_444 : August 31st, 2003 at 01:25 PM.

Reply With Quote
  #3  
Old August 31st, 2003, 01:24 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
you want to write an ftp client? you should probably read the ftp protocol so you understand exactly how the data transfers work. just connecting to the server and sending commands is easy, but transferring data is a bit more complex. you'll need to open up an additional port(20 i believe) to do the transfer. here is the ftp rfc, ftp://ftp.rfc-editor.org/in-notes/rfc959.txt

and here is some sample code of something i was workin on to get you started. this just connects and sees if the ftp is writeable, but it should give a rough idea of what to do.
Code:
#include "my_sock.h"

#define N_COMMANDS      6       //number of commands
#define PORT            21      //ermduh
#define SALEN           16      //sockaddr_in size
#define TIMEOUT         10      //listening TO

char    *command[] =    //these are the commands we send to ftp server
{
        "USER anonymous\r\n",
        "PASS asdf@aol.com\r\n",
        "SYST\r\n",
        "TYPE I\r\n",
        "PASV\r\n",
        "STOR fale\r\n"
};

int
main(int argc, char **argv)
{
        if(argc != 2) printf("Usage: %s <ip>\n", argv[0]),      exit(1);

        int     sock = 0,       nread = 0,      x = 0,  in_sz[N_COMMANDS];
        char    buf[ETH_FRAME_LEN];
        struct sockaddr_in      sa;
        struct timeval  ts;

        bzero(&sa, SALEN),      bzero(buf, ETH_FRAME_LEN),      bzero(&ts, sizeof(struct timeval));

        //setup address structure
        sa.sin_family = AF_INET;
        sa.sin_port = htons(PORT);
        sa.sin_addr.s_addr = inet_addr(argv[1]);

        ts.tv_sec = TIMEOUT;    //socket timeout

        //get the size of each command w/o NULL terminator and reset x
        for(x; x < N_COMMANDS; x++)
                in_sz[x] = strlen(command[x]);
        x = 0;

        printf(".-~'`ftp_find`'~-.\n"); //hi
        //create socket
        if( (sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
                perror("sock"), exit(0);

        //set timeout option
        if( (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &ts, sizeof(ts))) != 0)
                perror("setsockopt"),   exit(0);

        //open named pipe for reading and wait for input from other process
        //only wait for 1 hour at max then save and shutdown

        //connect to server
        if( (connect(sock, (struct sockaddr *)&sa, SALEN)) < 0)
                perror("con"), exit(0);
        else
                printf("connected to %s...\n", argv[1]);

        while(x <= N_COMMANDS)  //loop one extra time to read last reply
        {
                sleep(1);       //let the server breathe

                if(x < N_COMMANDS)      //skip sending in final loop
                {
                        if( (nread = write(sock, command[x], in_sz[x])) < 1)
                                perror("write"),        exit(0);

                        printf("sending command:%s", command[x]);
                }

                //a timeout indicates success if all commands have been sent,,,, USUALLY
                if( (nread = recv(sock, buf, ETH_FRAME_LEN, 0)) < 1)
                {
                        if(errno == EAGAIN)     //usually on success we timeout waiting for response
                                goto end;
                        else
                                perror("read"), exit(0);
                }

                //if a command isnt accepted/fails then the response code starts with a 4 or 5 like HTTP
                if( (buf[0] == '4') || (buf[0] == '5'))
                        printf("\ncommand rejected, moving on to next target\n"), exit(0);
                else
                        printf("...\n");
                x++;
        }

        //status and cleanup
end:
        if(x == N_COMMANDS)
                printf("Success, logging %s as pub\n", argv[1]);
        else
                printf("Failure\n");

        exit(1);
}

Reply With Quote
  #4  
Old August 31st, 2003, 05:46 PM
someonewhois someonewhois is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 88 someonewhois User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I personally use Wininet. Comes with Windows API SDK, and the DLL comes with IE. Most functions require IE 3 or IE 5, but if you "statically" link it and distribute the DLL, it doesn't need that.

Function list is here: http://msdn.microsoft.com/library/d...t_functions.asp

Hope this helps!

Regards,
Someonewhoi

Reply With Quote
  #5  
Old August 31st, 2003, 07:33 PM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
My suggestion is you create a simple FTP batch file and call it from the C system() command and save yourself a lot of trouble.
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
  #6  
Old September 1st, 2003, 12:07 AM
sai_student sai_student is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 sai_student User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thx a lot everyone ^^
What's that long script O_O"""""""""""""
arrrrrrrrrrrggghhhh
I'm going crazy T_T~

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > C language Ftp sending in windows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway