Article View: borland.public.jbuilder.java.language
Article #16748Re: SocketException -- Help Needed !!!
From: Terrence Coccoli
Date: Tue, 26 Jan 1999 00:00
Date: Tue, 26 Jan 1999 00:00
56 lines
2102 bytes
2102 bytes
Tor Iver Wilhelmsen wrote in message ...
>"Terrence Coccoli" <tscoccol@worldnet.att.net> writes:
>
>> I'm getting a SocketException when I attempt to create a socket. All I'm
>> doing is trying to connect to any stupid host at socket 1024. I'm
running a
>> W95 client. Here's the code. Please !!!! I need help.
>
>Well, if the host doesn't have a process listening at that port, you
>will get an exception. Have you made sure the host you try to reach is
>listening?
I changed the code somewhat to mimic that of code found in Elliote Rusty
Harold's Java Network Programming. He attempts to connect to
whois.internic.net at port 43. I am able to do so using Telnet but I can't
get the socket to do so. I also attemtp to connect to several webservers
(amazon.com, dell.com) which I can also do via Telnet but no luck with the
java code.
The weird things is I can use other java.net code like InetAddress without
problem.
Here's the latest code:
package Internet;
import java.net.*;
import java.io.*;
public class PortChecker {
public static String host;
public static int port;
public static void main(String[] args) {
Socket sock;
//System.out.println("port # " + port);
try {
host = args[0];
port = Integer.parseInt(args[1]);
sock = new Socket(host, port);
System.out.println("Server on port " + port + " on host " + host);
}
catch (IOException ioe) {
System.err.println(ioe);
ioe.printStackTrace();
}
}//main
}//class
Technical Details
Message-ID:
<78kvgd$n6@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<78j4pb$rdg7@forums.borland.com> <u4spew4d8.fsf@sds.no>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,165d8ccd4ca0739 X-Google-Attributes: gidf74b3,public From: "Terrence Coccoli" <tscoccol@worldnet.att.net> Subject: Re: SocketException -- Help Needed !!! Date: 1999/01/26 Message-ID: <78kvgd$n6@forums.borland.com> X-Deja-AN: 437181064 References: <78j4pb$rdg7@forums.borland.com> <u4spew4d8.fsf@sds.no> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language