🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2960

Simple Socket question

#2960
From: Suneet Shah
Date: Fri, 03 Jul 1998 00:00
44 lines
1977 bytes
Hello,

I am writing a routine to uses sockets to connect to and then send mail via
a smtp mail server.  In this case the server happens to be a Microsoft
Exchange server, howerver, that should not matter. The code that I have
written seems to work when I am in debug mode, but fails when I run in norma
execution mode.  It almost appears as though the stream is not yet ready to
read any data.  When in debug mode it alway works.

Thanks for your help.
Suneet

     sock   = new Socket(mailhost,25);   // by default a mail server listens
on 25
      inStrm = sock.getInputStream();
      din = new BufferedReader(new InputStreamReader(inStrm));
      outStrm= sock.getOutputStream();
      dout   = new PrintWriter(outStrm, true);
      response = GetResponse();                    **** This is where the
problem  seems to lie - The string that is read is null.
      retval = GetRetval(response," ");
////////////////////////////////////////////////////////////////////////////
///////////
String GetResponse()
  {
    StringBuffer sb = new StringBuffer();
    if (din == null)
      return null;
    try {
     while (din.ready())
     {
       if (sb.length() == 0)
          sb.append(din.readLine());
       else
          sb.append(" " +  din.readLine());
     }
    }
    catch(IOException e)
    {
      return null;
    }
     return sb.toString();
  }
Technical Details
Message-ID: <6nhok2$8cg18@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,103b4e9d2b8cd507,start
X-Google-Attributes: gid1089d0,public
X-Google-Thread: f74b3,103b4e9d2b8cd507,start
X-Google-Attributes: gidf74b3,public
From: "Suneet Shah" <suneet@diamelle.com>
Subject: Simple Socket question
Date: 1998/07/03
Message-ID: <6nhok2$8cg18@forums.borland.com>
X-Deja-AN: 368307946
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.api,borland.public.jbuilder.java.language