Can not create FTP socket from message handler

Hi all,

I’ve got a problem with connecting to an FTP server.
I’m calling a function which connectes to an FTP server with the following code:

ftpCommandChannel = wip_FTPCreateOpts(host, ftpCommandEventHandler, NULL, WIP_COPT_PEER_PORT, port, WIP_COPT_USER, user, WIP_COPT_PASSWORD, pass, WIP_COPT_FINALIZER, ftpCommandFinalizer, WIP_COPT_END);

Now the problem is that when I call this function from a command handler (adl_atCmdHandler_t) which I’m using for tests, everything is working fine. When I call the function from a message handler (adl_msgHandler_f), wip_FTPCreateOpts return a NULL pointer and prints the following error trace:
ERRLOG …/src/ftp.c:135: Can’t create control socket

I can’t find anything in the documentation (what a surprise) and unfortunately also not on the forum.
Can anyone help me out?

On this point I see two work arounds (haven’t tested them yet).

  1. I create a seperate task for FTP communication and let it wait on an event which I can trigger from the message handler
  2. I start a timer for 1 second so the FTP creation will be done in a timer handler

I don’t like both and the most important thing is that I don’t understand why I get this problem.

Please help.

thanks a lot

Is the FTP client being created on a separate task from the GPRS bearer (assuming a GPRS connection)? If so, are you calling


in the FTP task before trying to connect the FTP server?

I’m calling wip_netInit() in the main task, after that I create a connection with a server. That server will send the command to start the FTP communication, so I’m sure the initialization of the wip stack is done and OK.


Just remember that you have to call wip_netInit() in every task that uses WIP (eg: TCP client, FTP client etc). How are you creating the connection to the server first? Via TCP?

net init for every task? That’s new for me but sounds reasonable.

The connection with the server is indeed a TCP socket connection which is initiated by the main.

The program flow is like this:
Main task

  • inits wip stack
  • inits GPRS connection
  • GPRS eventhandler will start wip_TCPClientCreate (server connection\

Beside this task X will subscribe on messages from server connection.
This is the message handler which will initiate the FTP connection.
If i"m right, the message handler will run code under the same task ID as task X. right?
So the solution would be to init the wip stack also in the startup of task X?



Correct. Alternatively, just before you create the FTP connection.

I’m going to try it.

Thanks for your support!