Subj : telnet_gate
To   : Hemo
From : Digital Man
Date : Sun Sep 17 2000 09:15 am

RE: telnet_gate
BY: Hemo to Digital Man on Sun Sep 17 2000 02:51 pm

>  >  >   9/12  09:03:42p  !TELGATE ERROR 10038 sending on socket 404
>  >  >   9/12  09:03:42p  !ERROR 10038 closing socket 404
>  >  >   9/12  09:03:42p  Node 1 Telnet gate to myopia.ujoint.org finished
>  >
>  > This error simply means you aborted the connection attempt. Try being pat
>  > and waiting for the real connection failure message.
>
> OK, got my unix machine back up and running and started trying all this stuf
> again.
>
> Still don't work.  I let it sit for 133 minutes ( I went shopping ) and I st
> got no error, it just sat there.
>
> I have a LinkSys broadband router that links my internal network to the outs
> world.  My internal network is 192.168.1.  I have connectivity between my
> BBS machine (internal network 192.168.1.100 or delta.ujoint.org) and my unix
> computer (internal network 192.168.1.50 or myopia.ujoint.org).  I tested my
> connectivity by using ping, ftp, and telnet. These all work fine from either
> machine to either machine.
>
> Try running '*telgate myopia.ujoint.org' causes you to just hang there with
> connection.  running '*telgate delta.ujoint.org' works.  Now I am really
> confusinededed...ded.
>
> This behavior is identical if I am telneted into my BBS from inside my netwo
> or from an outside (other side of my router) host.
>
> my 'hosts' file( same on both my systems ):
> 192.168.1.100   delta delta.ujoint.org
> 192.168.1.50    myopia myopia.ujoint.org
>
>
> Since I do networking support as part of my real job, this is one of those
> things that I am determined to figure out why it doesn't work, and I am
> stumped.  I don;t know what's ahppening inside of the baja code for
> 'telnet_gate', but that's the only place I can figure this is going wrong...
>
> I have only one NIC on both systems, the IP's are static, SBBS has been boun
> to <ANY> and is now bound to 192.168.1.100 and all results are the same.
>
> Help?

I really don't have a clue as to why it isn't working. The telnet_gate function
simply opens a socket, binds it, and attempts a connect to the address (and
port) specified. Nothing complex. Here is the actual code:

void sbbs_t::telnet_gate(char* destaddr, ulong mode)
{
       char*   p;
       char    str[128];
       uchar   buf[512];
       int             i;
       int             rd;
       ulong   l;
       bool    gotline;
       ushort  port=IPPORT_TELNET;
       ulong   ip_addr;
       ulong   save_console;
       SOCKET  remote_socket;
       SOCKADDR_IN     addr;

       p=strchr(destaddr,':');
       if(p!=NULL) {
               *p=0;
               port=atoi(p+1);
       }

   if((remote_socket = open_socket(SOCK_STREAM)) == INVALID_SOCKET) {
               errormsg(WHERE,ERR_OPEN,"socket",0);
               return;
       }

       memset(&addr,0,sizeof(addr));
       addr.sin_addr.S_un.S_addr = htonl(cfg.startup->interface_addr);
       addr.sin_family = AF_INET;

       if((i=bind(remote_socket, (struct sockaddr *) &addr, sizeof
(addr)))!=0) {
               close_socket(remote_socket);
               lprintf("!ERROR %d (%d) binding to socket %d",i, ERROR_VALUE,
socket);
               return;
       }

       ip_addr=resolve_ip(destaddr);
       if(!ip_addr) {
               close_socket(remote_socket);
               lprintf("Failed to resolve addres: %s",destaddr);
               return;
       }

       memset(&addr,0,sizeof(addr));
       addr.sin_addr.S_un.S_addr = ip_addr;
       addr.sin_family = AF_INET;
       addr.sin_port   = htons(port);

       if((i=connect(remote_socket, (struct sockaddr *)&addr,
sizeof(addr)))!=0) {
               close_socket(remote_socket);
               lprintf("!ERROR %d (%d) connecting to server: %s"
                       ,i,ERROR_VALUE, destaddr);
               return;
       }

       l=1;

       if((i = ioctlsocket(remote_socket, FIONBIO, &l))!=0) {
               close_socket(remote_socket);
               lprintf("!ERROR %d (%d) disabling socket blocking"
                       ,i, ERROR_VALUE);
               return;
       }

       lprintf("Node %d Telnet gate to %s port %d on socket %d"
               ,cfg.node_num,destaddr,port,remote_socket);

       if(!(mode&TG_CTRLKEYS))
               console|=CON_RAW_IN;
       while(online) {
               gettimeleft();
               rd=RingBufRead(&inbuf,buf,sizeof(buf));
               if(rd) {
                       if(!(telnet_mode&TELNET_MODE_BIN_RX)) {
                               if(*buf==0x1d) { // ^]
                                       save_console=console;
                                       console&=~CON_RAW_IN;   // Allow
Ctrl-U/Ctrl-P
                                       CRLF;
                                       while(online) {
                                               SYNC;
                                               mnemonics("\1n\r\n\1h\1bTelnet
Gate: \1y~D\1wisconnect, "
                                                       "\1y~E\1wcho toggle,
\1y~L\1wist Users, \1y~P\1wrivate message, "
                                                       "\1y~Q\1wuit: ");
                                               switch(getkeys("DELPQ",0)) {
                                                       case 'D':

closesocket(remote_socket);
                                                               break;
                                                       case 'E':
                                                               mode^=TG_ECHO;

bprintf(text[EchoIsNow]

,mode&TG_ECHO
                                                                       ?
text[ON]:text[OFF]);
                                                               continue;
                                                       case 'L':

whos_online(true);
                                                               continue;
                                                       case 'P':
                                                               nodemsg();
                                                               continue;
                                               }
                                               break;
                                       }
                                       attr(LIGHTGRAY);
                                       console=save_console;
                               }
                               gotline=false;
                               if(mode&TG_LINEMODE && buf[0]!='\r') {
                                       ungetkey(buf[0]);
                                       l=K_CHAT;
                                       if(!(mode&TG_ECHO))
                                               l|=K_NOECHO;
                                       rd=getstr((char*)buf,sizeof(buf)-1,l);
                                       if(!rd)
                                               continue;
                                       strcat((char*)buf,crlf);
                                       rd+=2;
                                       gotline=true;
                               }
                               if(mode&TG_CRLF && buf[rd-1]=='\r')
                                       buf[rd++]='\n';
                               if(!gotline && mode&TG_ECHO) {
                                       RingBufWrite(&outbuf,buf,rd);
                                       SetEvent(output_event);
                               }
                       }
                       if((i=send(remote_socket,(char*)buf,rd,0))<0) {
                               lprintf("!TELGATE ERROR %d sending on socket
%d",ERROR_VALUE,remote_socket);
                               break;
                       }
               }
               rd=recv(remote_socket,(char*)buf,sizeof(buf),0);
               if(rd<0) {
                       if(ERROR_VALUE==WSAEWOULDBLOCK) {
                               if(mode&TG_NODESYNC) {
                                       SYNC;
                               }
                               mswait(1);
                               continue;
                       }
                       lprintf("!TELGATE ERROR %d receiving on socket
%d",ERROR_VALUE,remote_socket);
                       break;
               }
               if(!rd) {
                       lprintf("Node %d Telnet gate
disconnected",cfg.node_num);
                       break;
               }
               RingBufWrite(&outbuf,buf,rd);
               SetEvent(output_event);
       }
       console&=~CON_RAW_IN;

       /* Disable Telnet Terminal Echo */
       sprintf(str,"%c%c%c",TELNET_IAC,TELNET_WILL,TELNET_ECHO);
       putcom(str,3);

       close_socket(remote_socket);

       lprintf("Node %d Telnet gate to %s finished",cfg.node_num,destaddr);
}

(if that's of any help)

Rob

---
� Synchronet � Vertrauen � Home of Synchronet � telnet://vert.synchro.net