ios - FTPKit Abort (Cancel) FTP Operation -


i trying use github library ios: https://github.com/peqnp/ftpkit

the problem is, there no cancel function request need. trying implement own cancel function doesn't work crashing a: "write: bad file descriptor" exc_bad_access

in file specifically: https://github.com/peqnp/ftpkit/blob/master/libraries/include/ftplib/src/ftplib.c

i added method way @ bottom, use "abor" command ftp servers can use. not sure if right way of implementing it.

globaldef void ftpabort(netbuf *ncontrol) {     if (ncontrol->dir != ftplib_control)         return;     ftpsendcmd("abor",'2', ncontrol);     net_close(ncontrol->handle);     free(ncontrol->buf);     free(ncontrol); } 

then in ftpclient.m made method calls ftpabort method on netbuf * object (which can list, download, upload connection, etc..)

does see doing wrong here?

i'm using ftpkit , have need cancel function. think main problem approach closing , deallocating control buffers in ftpabort() function. if @ ftpxfer() function in libftp.c, try access same buffers have freed.

my approach add method ftpclient.m follows:

- (bool)canceloperation {     if (self.conn == null)         return no;     nsstring *command = [nsstring stringwithformat:@"abor"];     bool success = [self sendcommand:command conn:self.conn];     nsstring *response = [nsstring stringwithcstring:ftplastresponse(self.conn) encoding:nsutf8stringencoding];      if (!success) {         self.lasterror = [nserror ftpkiterrorwithresponse:response];         return no;     }     return yes; } 

the goal here tell ftp server close data connection should detected ftplib - will, in theory, exit properly. allow downloadhandle() method in ftpclient finish sending quit command should avoid crashing.

i "in theory" because in practice appears ftpxfer() doesn't spot until ftp server times out , closes entire connection. server has quick timeout (5 seconds) "good enough". although granted, nice have better solution.

i took suggestion comment made on ftpkit's github making netfbuf *conn property of ftpclient class.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -