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

Ftpcommand : PORT and NAT Firewall

1 view
Skip to first unread message

Eric Hamrick

unread,
Nov 4, 2002, 11:16:36 AM11/4/02
to
Hi,
I'm trying using use the Wininet library to send a file through a
firewall that does NAT translation. The interal pc has a external
address and a certain port range mapped on the firewall. I'm trying to
use FtpCommand to manually send the PORT command to the external ftp
server as follows.

HINTERNET hResponse,hFile;

hFtpSession = InternetConnect(hIntSession,address,21,"username","password",
(INTERNET_SERVICE_FTP),0,0);

hResponse = NULL
bRet = FtpCommand(hFtpSession, FALSE, FTP_TRANSFER_TYPE_ASCII,
"TYPE I", 0, &hResponse);
sprintf(ctemp,"ALLO %i",stats.st_size);
bRet = FtpCommand(hFtpSession,
FALSE,FTP_TRANSFER_TYPE_ASCII,ctemp, 0,&hResponse);
strcpy(ctemp,"PORT 111,111,111,111,111,111");
bRet = FtpCommand(hFtpSession, FALSE, FTP_TRANSFER_TYPE_ASCII,
ctemp, 0, &hResponse);
strcpy(ctemp,"STOR AAAAAAA.17C");
bRet = FtpCommand(hFtpSession, TRUE, FTP_TRANSFER_TYPE_BINARY,
ctemp, 0, &hFile);

...get data and loop function below until done.

(InternetWriteFile(hFile,readbuffer,sizeread,&byteswritten);


When the program executes the STOR Ftpcommand line it also sends
its own PORT command superceding the one I sent manually. I need the
PORT command to give the external address of the internal machine and
a limited port range to the external ftp server. Is there a way around
this????

Thanks in advance!

Eric Hamrick

Paul Denton

unread,
Nov 11, 2002, 1:10:45 PM11/11/02
to
Hello

I'm also trying to do something like this. In my case I have a Wininet
program that's suddenly is confronted with a server
on which FtpPutFile doesn't work. Also, I'm using FtpCommand to send manual
commands, and after the STOR
command I now have to make something to send data over. I thought my only
choice here was to somehow
get a reference to the socket, and use a Winsock function to send data.
InternetWriteFile has until now completely
slipped my mind.

I do not understand your question. Why do you have to use your PORT command
if the problem is to send
a file? Then, isn't it OK with the PORT command generated by the later
FtpCommand?
You also have the PASV command as an alternative to PORT. I think this is a
way to leave the
port problem over to the receiving server, but I'm not sure.

"the external address of the internal machine "

Do you mean the IP address to your local machine? In that case you can use
the winsock gethostname function, it works perfectly to just #include
winsock.h or winsock2.h
and use it. But there is more, I can tell you exactly if you write back.


Now, I'll try out InternetWritefile....

I'll be back. But tell me, are you getting the file over ?

Cheers /P


"Eric Hamrick" <hamr...@osu.edu> wrote in message
news:fc03c294.02110...@posting.google.com...

0 new messages