here is my code :
//open a data socket
acceptSock = NetLibSocketOpen(gNetRefNum, netSocketAddrINET,
netSocketTypeStream,
NetHToNS(6), timeoutticks, &err);
// Bind it to a local address
bzero((char*)&address, sizeof(address));
address.family = netSocketAddrINET;
address.port;
address.addr=0xc0a80011;
flag = NetLibSocketBind (gNetRefNum, acceptSock,
(NetSocketAddrType *)&address,
sizeof(address), timeoutticks, &err);
// Set the listen queue size
flag = NetLibSocketListen (gNetRefNum, acceptSock, 1,
timeoutticks, &err);
// Get our local address of the data socket and use the port number
addloclen = sizeof(datLocAddress);
addremlen = sizeof(datRemAddress);
flag = NetLibSocketAddr (gNetRefNum, acceptSock,
(NetSocketAddrType *)&datLocAddress, &addloclen,
(NetSocketAddrType *)&datRemAddress, &addremlen,
timeoutticks, &err);
// Get local address for the control socket. We have to use the IP address from
this socket since the data socket isn't connected yet.
addloclen = sizeof(ctlLocAddress);
addremlen = sizeof(ctlRemAddress);
flag = NetLibSocketAddr (gNetRefNum, sock,
(NetSocketAddrType*)&ctlLocAddress, &addloclen,
(NetSocketAddrType *)&ctlRemAddress, &addremlen, timeoutticks,
&err);
StrPrintF(FTPCommand, "PORT 192,168,0,17, %d,%d\r\n",
ctlLocAddress.port >> 8,
ctlLocAddress.port & 0x00FF);
flag = NetLibSend(gNetRefNum, sock, (void*) FTPCommand,
StrLen(FTPCommand), 0, (void*)&ctlRemAddress,
sizeof(ctlRemAddress), timeoutticks, &err);
now the ftp server show:200 PORT Command successful.
then I try to send a stor command to ftp server, I get a error
message:150 Opening BINARY mode data connection for test.txt.
425 Cannot open data connection.
how can I open a data connection to send a txt file? please help me.
|