|
Hi Andreas,
A few things jump out at me in your code... I thought I'd mention them,
in case they help you troubleshoot the problem.
1) in telnet_stream_wait_string you're reading data from the connection
by using the telnet_stream_get_next() function. This function
will return immediately unless you've set "This->msec_wait".
By default, the timeout value is 0, so it returns immediately.
(This causes your code to continue, thinking it got the proxyPrompt,
when it actually didn't)
2) When you do your telnet_stream_write() to write the proxyCmd, you
probably also want to send a CR/LF (or maybe just CR, or just LF,
depending on what your tn-gw software is looking for)
3) If your tn-gw software returns something like "connecting to
w.x.y.z... connected!" you'll want to search for that data and
strip it out before finishing the telnet_stream_connect() function.
Thats all I can see from just looking at your code :) What tn-gw
software are you using? I'm sure if I could set one up as a test, I
could find more problems :)
Hope that helps!
On Wed, 19 Jul 2000, Hilbig, Andreas wrote:
> Hi,
>
> first I want to thank you all for your comments. I think I'll try to
> implement
> it the way Scott dreamt because indeed I think it's not such a not-normal
> situation to have security-mechanisms like tn-gw between client and AS400.
>
> My first attempt wasn't successfull, because I didn't read the whole source
> -
> and so I don't now how to send a string to the tn-gw and when to query the
> stream for the tn-gw-prompt.
> However... I made a guess and modified telnet_stream_connect by adding the
> following lines befor the 'return 0':
>
> if (proxyPrompt) {
> telnet_stream_wait_string(This, proxyPrompt);
> }
>
> if (proxyCmd) {
> telnet_stream_write(This, proxyCmd, strlen(proxyCmd));
> }
>
> Therefore I wrote the following telnet_stream_wait_string - function:
>
> /****i* lib5250/telnet_stream_wait_string
> * NAME
> * telnet_stream_wait_string
> * SYNOPSIS
> * ret = telnet_stream_wait_string (This);
> * INPUTS
> * Tn5250Stream * This -
> * char * searchstr -
> * DESCRIPTION
> * Reads data from the stream until specified string appears;
> * Returns 0 if successfull or -1 if no data is
> * currently available on the socket or -2 if we have been disconnected.
> *****/
> static int telnet_stream_wait_string(Tn5250Stream * This, char * searchstr)
> {
> int rc = 0;
> int bnfound = 1;
> int len = strlen(searchstr);
> int nbuf=0;
>
> char *buf = (char *) malloc(len+1);
>
> buf[0]=0;
> buf[len] = 0;
> while (rc >=0 && bnfound) {
> rc = telnet_stream_get_next(This);
> printf((char) rc);
> if (rc>=0) {
> buf[nbuf]= (char) rc;
>
> if (nbuf < len-1)
> nbuf++;
> else {
> bnfound=strcmp(buf, searchstr);
> strcpy(buf, buf+1);
> }
> }
> }
>
> if (!bnfound)
> rc = 0;
> free(buf);
> return rc;
> }
>
>
> The result was endless waiting... I guess it wasn't enough negotiation
> before querying the
> stream.
>
> Who can give me a hint ?
>
>
+---
| This is the LINUX5250 Mailing List!
| To submit a new message, send your mail to LINUX5250@midrange.com.
| To subscribe to this list send email to LINUX5250-SUB@midrange.com.
| To unsubscribe from this list send email to LINUX5250-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.