Nuno Carvalho wrote:

> > Looking at your mail again, it appears that you are writing both the
> > client and the server part of this application - if so, then you
> > shouldn't be touching telnet options at all 
> 
>  No. I'm just doing the server. My project is to do a BBS(Bulletin Board
> Service) server. Finally I already had non-echo working as I want! :)
> 
>  Meanwhile, I'm having other problem:
> 
>   I would like to be able to send bold, underline or even colors to the
> client(which connects to my server by telnet <machine> <port>). It seems I
> that I need to use terminfo but with socket seems to be more complicated.
> :(
> 
>   1. I don't want to use dup2() to use stdout as socket descriptor! I need
> stdout to send results from server(like: got connection from
> 127.0.0.1 on port # 2344).

A server shouldn't be writing to the stdout/stderr which it inherited. 
It should use either a logfile or the syslog facility for this.

Also, note that tputs() uses the function which is provided as the
third argument to actually send each character. Instead of using
putchar(), write your own function which uses fputc to write the
character to the socket.

>   2. I'm trying to use terminfo with success *but* when using tigetstr() I
> get "Segmentation Fault" ! :(
> 
>        char *tigetstr(const char *capname);
> 
>   This Segmentation Fault only happens, to me, when capname's variable
> don't exist on terminfo(5) ! So, I don't have no chance to control it, I
> I think.

It sounds as if you're not checking the return value from tigetstr(). 
It will return `(char *)-1' if the capability doesn't exist, or isn't
a string-valued capability. If you attempt to dereference this, you
will get a segfault.

>  3. What I do on my program is to get the result of tigestr() - when it
> works - and remove the "$<2>" from the that result! So that I get
> something like "[1m" and send it to the client descriptor. It seems to
> work.
>   I don't do any test to the remote machine about it environment variable.
> I just do:
> 
>  setupterm( "vt100", client_fd, (int*)0 ); 

This will only work if the client happens to use the same escape
sequences as a vt100.

The bottom line is that you are trying to do too many things yourself. 
You should be using inetd to handle the connection, and in.telnetd to
handle the telnet protocol. Your program should just assume that there
is a terminal connected to stdin/stdout.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to