cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: a poor telnet example -- but you don't have to enter the password

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 16 May 2003 13:13:54 +0200 (CEST)

On Thu, 15 May 2003, Dan Leonard wrote:

(Since this is a library-using app, I took this reply over to the
curl-library list.)

> I was trying to use the curl library for telnet where I don't have to enter
> the password at a terminal; I do this because I want it to talk to a router
> via an UI. I figured out a way, using "telnet://localhost", and a write
> callback function. The biggest problem is that I have to assume the socket
> connection back to the the telnetd daemon is "3", i.e. 0,1,2, are stdin,
> stderr, stdout. This is a pretty good assumption, at least for a very
> short program.
>
> I see in 7.10 there might be ways of using "multi" to get file desciptors,
> and to exit gracefully. This is a little new, as the system I am working
> on is redhat 7.2 or 7.3, which has 7.9 curl naturally installed. I guess I
> could install 7.10. Ayway, here is the poor example is attached.

libcurl's main paradigm is that it transfers files, either way. It is not
very good at sending a little chunk now and little chunk then, as telnet
requires.

To make libcurl more suitable for telnet, we should add two mechanisms in the
API:

 1. Enable the application to tell the library that we have data to send, or
    that we don't have data to send. The current workings assume that we will
    continue sending data until there no longer is any, and then we're done.

 2. The reversed. Allow and application to tell the library that we are not
    prepared to receive any more data right now. The only kind of
    flow-control an app has now, is to sleep in the callback before it
    returns control back to the library and it certainly isn't very nice.

In your telnet case, you could skip your work-around for file descriptor 3 if
the first item in this list was added.

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
Received on 2003-05-16