LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

InetFTPGetDir, System Socket Error

hi,

when i was trying with InetFTPGetDir() InetFTPGetDirList function i am getting System socket error, i tried with the sample program ftpclt.cws as mentioned in one of the thread, even though i am getting same socket error. dont know wr the probelm is..... pls help me to get this done.

0 Kudos
Message 1 of 8
(4,531 Views)

In one of your previous posts, you mentioned the successful use of the InetFTPAutoReceive() function. As this function needs the same parameters as your InetFTPLogin() function, to get a handle for InetFTPGetDirList(), it is difficult to tell what is wrong, unless there is an error in your code. What exactly does the error message say? Can you post some of your code for us to have a look at?

 

JR

0 Kudos
Message 2 of 8
(4,523 Views)

herby my sample code. i am getting system socket error in InetFTPGetDir().if i call InetFTPGetDirList() i am reading the folder names inside the current directory.but in my case by default my ftp server has some 5 folder and i need to read the files available inside any of the folder say "reports/" folder as shown in the attachment picture.so how can i read the files name inside the folder "ftp://10.105.148.139/reports/".

 

int CVICALLBACK getftpfiles (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char ipaddr[100],uname[50],paswd[50]; switch (event) { case EVENT_COMMIT: GetCtrlVal(panelHandle,PANEL_STRING,ipaddr); GetCtrlVal(panelHandle,PANEL_STRING_2,uname); GetCtrlVal(panelHandle,PANEL_STRING_3,paswd); ftphandle = InetFTPLoginEx(ipaddr,uname,paswd,6000); error = InetFTPSetPassiveMode (ftphandle, 1); if(error<0) Error (error); getfilesfromFTP(); break; } return 0; } void getfilesfromFTP(void) { char dir[MAX_PATHNAME_LEN]; char ftp_dir[MAX_PATHNAME_LEN]; char **files = NULL; int num; error = InetFTPGetDir(ftphandle,dir,MAX_PATHNAME_LEN); /*here i am getting system socket error*/ if(error <0) Error (error); error = InetFTPGetDirList (ftphandle, &files, &num); /*here i am getting system socket error*/ if(error<0) Error(error); Fmt(ftp_dir,"%sreports/",dir); InetFTPChangeDir(ftphandle,ftp_dir); /*change FTP dir to ftp://10.105.148.139/reports/ */ /* now i need to get the file name available inside reports folder ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ ----------------------------------------------------------------------------*/ error = InetFTPClose(ftpHandle); if(error<0) Error(error); }

 

0 Kudos
Message 3 of 8
(4,507 Views)
just to be sure: did you check for a valid value of ftphandle?
0 Kudos
Message 4 of 8
(4,498 Views)
yes. its valid ftphandle. i have defined ftphandle as global.
0 Kudos
Message 5 of 8
(4,496 Views)

finally i got the solution by having InetFTPGetDirList () function to retrive files from remote to local

thanks a lot for JR & Wolfgang

0 Kudos
Message 6 of 8
(4,477 Views)

Would you mind to tell us what the reason was? Might be interesting for other users, too.

0 Kudos
Message 7 of 8
(4,475 Views)

Initally i thought of getting dir name through InetFTPGetDir() and changing the directory with "reports" folder through InetFTPChangeDir() and getting number of files avilable in changed directory through InetFTPGetDirList. when i started with InetFTPGetDir() it keeps on showing system socket error so that i could not able to move to next step in which other 2 funcitons also shows the same error.

 

i commented InetFTPGetDir() and started calling InetFTPChangeDir(ftphandle,"reports") and getting the files available in that dir. it reads well.....

i got stuck up with the system socket error in InetFTPGetDir() if i remove that line my code is working fine. All this functions is called after successful FTP login.

 

0 Kudos
Message 8 of 8
(4,465 Views)