Socket wird nicht ausgeführt

Status
Nicht offen für weitere Antworten.

Reality

Top Contributor
Hi,
bei dem Beispielprogramm steht folgendes:

Wenn Sie in der Befehlszeile osborne.com eingben, erscheint die entsprechende Ausgabe:
blablabla

Nur erscheint bei mir gar nichts, nicht mal wenn ich etwas eingebe! Wenn ich osborne.com eingebe und dann Enter drücke, macht es einfach eine neue Zeile. Auch wenn ich über JBuilder den Parameter osborne.com übergebe, steht folgendes da:

whois osborne.com

Wenn ich dann Enter drücke, macht es wieder einfach eine neue Zeile. Dies geschieht alles in der "Konsole" von JBuilder.

Code:
import java.net.*;
import java.io.*;

public class Whois {
  public static void main(String[] args) throws UnknownHostException, IOException{
    int c;
    //Gibt das mit dem Socket verbundene InpuStream zurück :-)
    Socket s = new Socket("internic.net", 43);
    InputStream in = s.getInputStream();
    OutputStream out = s.getOutputStream();

    String str = args.length == 0? "osborne.com" : args[0];
    byte buf[] = str.getBytes();
    out.write(buf);

    while((c = in.read()) != -1)
      System.out.print((char) c);


  }
}

Liebe Grüße
Reality
 
Oh man! 😳
Habe gedacht der Autor schreibt da Schwachsinn aber man muss das doch so schreiben, warum auch immer:

Code:
String str = (args.length == 0? "osborne.com" : args[0]) + "\n";

Liebe Grüße
Reality
 
Ähm, lol? ???:L

Whois Server Version 1.3

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

Aborting search 20 records found .....
MICROSOFT.COM.SUX.BUT.PYROFREAK.ORG.RULEZ.AND.DIOXYTECH.NET.DELETED.GANDI.NET
MICROSOFT.COM.SMELLS.SIMPLECODES.COM
MICROSOFT.COM.SHOULD.GIVE.UP.BECAUSE.LINUXISGOD.COM
MICROSOFT.COM.RAWKZ.MUH.WERLD.MENTALFLOSS.CA
MICROSOFT.COM.OHMYGODITBURNS.COM
MICROSOFT.COM.LOVES.JU1C3.COM
MICROSOFT.COM.LIVES.AT.SHAUNEWING.COM
MICROSOFT.COM.IS.NOT.AS.COOL.AS.SIMPLECODES.COM
MICROSOFT.COM.IS.IN.BED.WITH.CURTYV.COM
MICROSOFT.COM.IS.GOD.BECOUSE.UNIXSUCKS.COM
MICROSOFT.COM.IS.A.STEAMING.HEAP.OF.FUCKING-BULLSHIT.NET
MICROSOFT.COM.HAS.TEH.GAY.OMFGLOL.COM
MICROSOFT.COM.HAS.ITS.OWN.CRACKLAB.COM
MICROSOFT.COM.HAS.A.PRESENT.COMING.FROM.HUGHESMISSILES.COM
MICROSOFT.COM.FLINGS.POO.AT.MONKEYCORE.COM
MICROSOFT.COM.FILLS.ME.WITH.BELLIGERENCE.NET
MICROSOFT.COM.CAN.GO.FUCK.ITSELF.AT.SECZY.COM
MICROSOFT.COM.ARE.GODDAMN.PIGFUCKERS.NET
MICROSOFT.COM.AND.MINDSUCK.BOTH.SUCK.HUGE.ONES.AT.EXEGETE.NET
MICROSOFT.COM

To single out one record, look it up with "xxx", where xxx is one of the
of the records displayed above. If the records are the same, look them up
with "=xxx" to receive a full display for each record.

>>> Last update of whois database: Fri, 30 Jul 2004 08:43:37 EDT <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

Liebe Grüße
Reality
 
Reality hat gesagt.:
Oh man! 😳
Habe gedacht der Autor schreibt da Schwachsinn aber man muss das doch so schreiben, warum auch immer:

Code:
String str = (args.length == 0? "osborne.com" : args[0]) + "\n";

Liebe Grüße
Reality


\n muss wahrscheinlich am ende deines stromes ergänzt werden, weil auf der serverseite die zeichen mit readline() gelesen werden. und ohne \n fängt da dann niemand an zu arbeiten 🙂
 
Schreib lieber am ende so
Code:
String str = (args.length == 0? "osborne.com" : args[0]) + "\r\n";

Damit die unix welt auch bedient ist.

mfg ff
 
flashfactor hat gesagt.:
Schreib lieber am ende so
Code:
String str = (args.length == 0? "osborne.com" : args[0]) + "\r\n";

Damit die unix welt auch bedient ist.

mfg ff


Du meinst die Windows Welt...\n ist für Unix OK..
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben