[comp.protocols.tcp-ip.ibmpc] Problem with FTP libraries using ftp calls.

seth@wet.UUCP (Seth Olitzky) (11/09/90)

I have found a problem that I don't understand in the FTP development
libraries.  I am using the FTP calls such as ftp_open and ftp_get.  
I am trying to connect to mulitple hosts using ftp_open and then do
transfers one at a time with ftp_get.  By opening the channel 
from the beginning I minimize connect time on each file transfer.

Basically I do the following loop.

for (i=0;i<max_channels;i++) {
	host_con[i] = ftp_open(host_id[i], 512,512,0);
}

then I do the transfer

for (i=0;i<max_channels;i++) {
	status = ftp_get(host_con[i],filename[i],handler);
}

The problem is that I can only sucessfully handle three connections.  
Soon as I use four connections I fail with error 3

  choose_port: net_listen(): Out of resources (memory/connections).

I have enough memory since my heap is very large.  The problem appears
to be with the allocation of network descriptors.  I put in some 
debuggin and looked at the value of the network descriptors.

The values for the Network descriptors and the data network descriptors were

Channel    ND  DND
0          5   -1
1          6   -1
2          7   -1
3          8   -1

The descriptors 5,6,7,8 appear to correspond to the file handles that
are available (0-4 being used as stdin, stdout, stdaux, stderr, and stdprint).
So this looks kosher.  The -1 indicates that the descriptor will be
allocated during the ftp_get.

Since a DOS process can have 20 file handles I should be able to open
about 7 channels (20max -5used)/2 = 7.

I can't even open four.

I then tried to do a fclose on stdin, stdprint, stderr, and stdaux, but
left stdout open.  This changed the ND values to 0,1,3,4 as expected.
But again the program failed with error code three on the first ftp_get.

I don't understand what I am missing.  Shouldn't I be able to open more
channels at once.  Is there some other limitation in the ftp libraries that
I don't know about?  

Any help, info would be much appreciated?
 
-- 
-----------------------------------------------------------------------------
Seth Olitzky             seth@wet
         ...!sun!hoptoad!wet!seth
----------------------------------------------------------------------------

pmoore@hemel.bull.co.uk (Paul Moore) (11/09/90)

The problem is that you must up the number of allowed connections in the ftp
kernel (3 or 4) is the default. On the line that loads the kernel in
your autoexec.bat (3c503 or ethdrv or whatever) add -t 8 to increase
the number of tcp sessions to 8. It makes the kernel a bit bigger.

Good luck

PS I have an encapsulation of tcp streams into zortech C++ streams
if you are interested