From owner-freebsd-java@FreeBSD.ORG Wed Aug 6 15:11:44 2003 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5AE9E37B404 for ; Wed, 6 Aug 2003 15:11:44 -0700 (PDT) Received: from ms-smtp-03.southeast.rr.com (ms-smtp-03.southeast.rr.com [24.93.67.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1625743F75 for ; Wed, 6 Aug 2003 15:11:43 -0700 (PDT) (envelope-from mmercer@nc.rr.com) Received: from [192.168.1.2] (rdu88-246-041.nc.rr.com [24.88.246.41]) h76M9f3M015424; Wed, 6 Aug 2003 18:09:41 -0400 (EDT) From: "Michael E. Mercer" To: "Lapinski, Michael (Research)" In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-aqumX4pxvqAGS3m5zreH" Message-Id: <1060207897.13023.13.camel@dual.mmercer.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 06 Aug 2003 18:11:37 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.1 cc: freebsd-java@freebsd.org Subject: RE: Socket Exception using 1.4 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: mmercer@nc.rr.com List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2003 22:11:44 -0000 --=-aqumX4pxvqAGS3m5zreH Content-Type: text/plain Content-Transfer-Encoding: 7bit Attached you will find LRC.java... LRC=Linksys Router Connection This code when run by version 1.3 works fine. When run by 1.4, it throws a SocketException. Here is the code inline... it throws the exception at the readLine() call. to run it, the params are username of the Linksys Router password for Linksys Router IP address assigned to the Linksys Router the page you want to retrieve Thanks MeM /* * Created on Aug 6, 2003 */ package com.mmercer.lrc; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; /** * @author mmercer */ public class LRC { /** * */ public LRC() { super(); } public String retrievePage(String host, String page) { StringBuffer result = new StringBuffer(); URL url = null; try { // do stuff here. url = new URL("http", host, 80, "/" + page); // System.out.println( url.toString() ); URLConnection conn = url.openConnection(); // update headers here... conn.connect(); InputStreamReader isr = new InputStreamReader(conn.getInputStream()); BufferedReader br = new BufferedReader(isr); String line = null; while (br.ready() && ((line = br.readLine()) != null)) { result.append(line).append("\n"); } } catch (Exception e) { e.printStackTrace(); } return result.toString(); } public static void main(String[] args) { if (args.length != 4) { System.err.println( "usage: java LRC "); System.exit(1); } LRC lrc = new LRC(); Authenticator.setDefault(lrc.new MyAuthenticator(args[0], args[1])); String result = lrc.retrievePage(args[2], args[3]); if (null == result) return; System.out.println(result); } class MyAuthenticator extends Authenticator { private PasswordAuthentication pw; MyAuthenticator(String username, String password) { pw = new PasswordAuthentication(username, password.toCharArray()); } protected PasswordAuthentication getPasswordAuthentication() { return pw; } } } On Wed, 2003-08-06 at 15:21, Lapinski, Michael (Research) wrote: > One suggestion, try using NetworkInterface > to poll for up/down/ip info (I read a short > Article in the java developers journal about > it and would be willign to fax it to you or > Something). > > Second, the first thing that comes to mind > is policy files for the JVM, ive seen a lot > of weird socket excpetions with RMI stuff > that ended up being policy issues. > > If that doesn't do anything send a code > snippet and maybe I can be of help. > > > -mtl > > -------------------------------------------------- > Michael Lapinski > Computer Scientist > GE Research > > -----Original Message----- > From: Michael E. Mercer [mailto:mmercer@nc.rr.com] > Sent: Wednesday, August 06, 2003 3:08 PM > To: freebsd-java@freebsd.org > Subject: Socket Exception using 1.4 > > > Hello, > > I have a Linksys Router that I access via a java program to get my current > IP. > > I use my own Authenticator and use URL to get a URLConnection. > > When I use 1.3, everything works just fine. > > However using 1.4 throws a "Socket Reset" SocketException everytime. > > If you need me to write a sample code snippet to explain what exactly I'm > doing, then I will. > > Thanks > Michael Mercer > > _______________________________________________ > freebsd-java@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" --=-aqumX4pxvqAGS3m5zreH--