🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15581

socket problem

#15581
From: Hans Georg Frey
Date: Sun, 23 May 1999 00:00
60 lines
2140 bytes
Hi,

I wrote a simple Client and Server using Socket and ServerSocket.

Running both Client and Server on the same machine everything works
fine. Running on different machines accept() returns a new Socket
Object.
from my Client request. But reading and writing on the Socket blocks.

Have I made something wrong? Ist the any mechanism from the host
administrator,
which accepts an connect but no read and write?

Thanks, by
Hans Georg

This is the program from java in a nutshell examples:


public class HttpMirror
{
  public static void main( String args[] )
  {
    try
    {
      int iPort = Integer.parseInt( args[0] );
      ServerSocket ss = new ServerSocket( iPort );
      System.out.println( "New Server on Port: " + iPort );
      while( true )
      {
        Socket client = ss.accept();
        System.out.println( "Acceptet" );
        BufferedReader in =  new BufferedReader(
                  new InputStreamReader( client.getInputStream() ));
        PrintWriter out = new PrintWriter(
                  new OutputStreamWriter(  client.getOutputStream() ));
        out.println( "HTTP/1.0 200" );
        out.println( "Content-Type: text/plain" );
        out.println();
        out.flush();

        String sLine;
        while(( sLine = in.readLine()) != null )
        {
          if( sLine.length() == 0 )
            break;
          out.println( sLine );
        }
        out.close();
        in.close();
        client.close();
      }
    }
    catch( Exception e)
    {
      System.err.println( e );
      System.err.println( e.getMessage() );
    }
  }
}
Technical Details
Message-ID: <374872D2.A16F1718@she.de>
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: f74b3,b7fd7e1ae79ebf0a,start
X-Google-Attributes: gidf74b3,public
From: Hans Georg Frey <hfrey@she.de>
Subject: socket problem
Date: 1999/05/23
Message-ID: <374872D2.A16F1718@she.de>
X-Deja-AN: 481285887
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
X-Accept-Language: de
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language