Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I put file using tftpXfer(), ftpXfer()

534 views
Skip to first unread message

Kwon,YongWook

unread,
May 5, 2004, 9:55:40 AM5/5/04
to
Hi seniors?

I receive files to tftp server with tftpXfer().
"get"

But I don't know exactly how to send file to tftp Server using tftpXfer()
"put"


And I want to know how to send file using ftpXfer()
"STOR"


No one tell about it in Google page.

Plase give me some advice.

Regards,
Wook

joe durusau

unread,
May 5, 2004, 11:31:35 AM5/5/04
to

"Kwon,YongWook" wrote:

Try reading the manual. It seems pretty clear to me. Note: many hosts
will not allow a transfer to the host by tftp, but that's not really a
vxWorks
problem.

Speaking only for myself,

Joe Durusau


Vasu Dalal

unread,
May 8, 2004, 9:38:33 PM5/8/04
to
Hello Wook:

> And I want to know how to send file using ftpXfer()
> "STOR"


Here is a sample code:

strServerHostName: Hostname of the server
strLogin: login id on the server
strPasswd: Password for the login id
destFileName: destination filename
srcFileName: source filename

I hope you can complete the rest.

The code for TFTP will be similar.

hth,
vasu

PS:

[snip]

char ftpBuffer [MAX_FTP_BUFFER_SIZE];
int fd = -1;
int writeFd = -1;
int readFd = -1;
int errFd = -1;
int retvalue = OK;
int bytes_read = 0;
UINT32 nBytes = 0;

.
.
.

if ( ftpXfer(
strServerHostName, /* name of server host */
strLogin, /* user name for host login */
strPasswd, /* password for host login */
"", /* account for host login */
"STOR %s", /* command to send to host */
"", /* directory to cd to before sending
command */
destFileName, /* filename to send with command */
&errFd, /* where to return control socket fd
*/
&fd /* where to return data socket fd,
(NULL == don't open */
/* connection) */
) == ERROR )
{
printf("ftpXfer() failed! errno = 0x%x.\n",errnoGet());
return(ERROR);
}

readFd = open (srcFileName, O_RDONLY, 0644);
if ( ERROR == readFd )
printf("open error\n");

bytes_read = 0;
nBytes = 0;
while ( (bytes_read = read (readFd, ftpBuffer, MAX_FTP_BUFFER_SIZE)
) > 0 )
{
nBytes += bytes_read;
if ( nBytes % (1024*50) == 0 )
printf(".");
if ( write(fd, ftpBuffer, bytes_read) < bytes_read )
{
printErr("fileFtpNew() :: Bad write. errno = 0x%x\n",errnoGet());
retvalue = ERROR;
break;
}

[snip]

0 new messages