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
 

Reality

Top Contributor
Oh man! :oops:
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
 

Reality

Top Contributor
Ä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
 

citizen_erased

Bekanntes Mitglied
Reality hat gesagt.:
Oh man! :oops:
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 :)
 

flashfactor

Aktives Mitglied
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
 

meez

Top Contributor
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.
Ähnliche Java Themen
  Titel Forum Antworten Datum
A Socket Socket-Problem - Object wird nicht übertragen Netzwerkprogrammierung 3
B Socket wird nicht richtig geschlossen Netzwerkprogrammierung 2
I Socket ObjectOutputStream-Socket: Objekt wird falsch übertragen Netzwerkprogrammierung 2
M Client sendet nur, wenn das Socket geschlossen wird Netzwerkprogrammierung 53
A Socket BufferedReader.readLine() blockiert bis ein im Socket OutputStream was gesendet wird ... Netzwerkprogrammierung 9
G Socket wird nach Portscann geschlossen Netzwerkprogrammierung 2
W Socket Server -> lesen von / schreiben zu php-script Netzwerkprogrammierung 6
B Versuch mit Socket etwas zu lesen und zu schreiben Netzwerkprogrammierung 15
G Socket Socket Kommunikation Netzwerkprogrammierung 1
L Server-Socket liest Input-Stream nicht Netzwerkprogrammierung 5
H Socket Kann ein Socket server 2 dimensionale Arrays empfangen und versenden? Netzwerkprogrammierung 3
D Socket-Verbindungen übers Internet Netzwerkprogrammierung 4
Z Kann nicht Daten vom Server lesen Socket Netzwerkprogrammierung 10
N Java socket Programmierung Filme verschicken Netzwerkprogrammierung 20
A TCP multiClientServer mit socket mittels ObjectOutputStream Netzwerkprogrammierung 12
A Socket-Anwendung (BufferedWriter/Reader liest nicht aktuellen Wert) Netzwerkprogrammierung 6
platofan23 Socket Java Socket mit DynDns nicht erreichbar Netzwerkprogrammierung 6
S Socket Bilder über Socket Senden Netzwerkprogrammierung 0
M Socket Socket lehnt Verbindung ab Netzwerkprogrammierung 3
x46 Connection reset by peer: socket write error Netzwerkprogrammierung 6
x46 Socket Files per Socket verschicken Netzwerkprogrammierung 1
platofan23 Probleme mit Socket bei Android Studio? Netzwerkprogrammierung 22
platofan23 Socket Hilfe mit Socket Thread und ArrayList Netzwerkprogrammierung 6
R Socket FATAL EXCEPTION MAIN bei Socket based client/server app Netzwerkprogrammierung 2
D new ObjectInputStream(socket.getInputStream()); Netzwerkprogrammierung 15
E Socket Frage Netzwerkprogrammierung 6
D ServerSocket - Socket Verbindungsart Netzwerkprogrammierung 3
T Frage bzgl. Socket-API Netzwerkprogrammierung 1
F TCP Socket auf Verbindungsabbruch prüfen Netzwerkprogrammierung 15
F Socket Verbindung mit Verschlüsselung und Authentifierzung Netzwerkprogrammierung 1
T Socket Socket connections schließen? Netzwerkprogrammierung 2
D Socket Socket OutputStream leeren? Netzwerkprogrammierung 3
T Socket Java Programm hängt sich auf bei dem versuch von einem Socket scanner Daten zu erhalten. Netzwerkprogrammierung 1
F Socket Socket in anderen Methoden Netzwerkprogrammierung 1
D Socket Run Args Client/Server Socket Netzwerkprogrammierung 1
M Problem bei Socket (MultiplayerSpiel) Netzwerkprogrammierung 4
I Socket Netzwerkprogrammierung 1
F Wiederverbinden nach socket Abbruch Netzwerkprogrammierung 1
J 1 Socket - 2 Serversocket Netzwerkprogrammierung 4
T Socket sendet erst nach socket.close() Netzwerkprogrammierung 2
F Socket Verbindungsaufbau abbrechen Netzwerkprogrammierung 3
P Socket Socket-Verbindung Input sehr langsam Netzwerkprogrammierung 1
I Socket Kommunikation C / Java Netzwerkprogrammierung 2
Joew0815 socket event handler Netzwerkprogrammierung 2
F Einfache Socket Verbindung Netzwerkprogrammierung 2
A Socket Socket Receive-/SendBuffersize Netzwerkprogrammierung 0
D Socket server auf Smartphone Netzwerkprogrammierung 9
H Socket Client/Server Socket Programmieren Netzwerkprogrammierung 1
A Socket Socket Server netcat Netzwerkprogrammierung 1
Shams Anfängerfrage zu Server-Socket-Kommunikation Netzwerkprogrammierung 2
M Socket String Arrays über Socket an Server schicken Netzwerkprogrammierung 2
D Socket Error: java.lang.NullPointerException Netzwerkprogrammierung 1
D TCP Socket funktioniert nicht richtig Netzwerkprogrammierung 3
X Problem mit vielen Bytes über Socket Netzwerkprogrammierung 23
B SSL Socket Netzwerkprogrammierung 2
R Dauerhaft offene Socket-Verbindung? Netzwerkprogrammierung 3
S Socket (client) verbindet nicht Netzwerkprogrammierung 6
G Socket Socket verbindung für Chat System Netzwerkprogrammierung 3
P Warum kann ich kein Socket aufbauen? Netzwerkprogrammierung 12
S Socket SSL Socket und Sun/Oracle Java Netzwerkprogrammierung 5
S Socket Socket Verbindung wiederherstellen Netzwerkprogrammierung 16
precoc Server Socket Start / Stop Netzwerkprogrammierung 5
N SOCKET mehrere Requests, keep Alive serverspezifisch? Netzwerkprogrammierung 3
S ImageIcon über Socket schicken (Serialisierung) Netzwerkprogrammierung 6
C Socket Systemsperren mit Socket Netzwerkprogrammierung 4
H Socket Objekte über Socket? Allgemeine Verständnisprobleme in Sachen Socket Netzwerkprogrammierung 3
D Socket Multithread-Socket | Kurz vor dem Ziel Netzwerkprogrammierung 7
C Datei über Socket schreiben und Ereignis lesen Netzwerkprogrammierung 9
D Socket Dynamische Socket-Thread Erzeugung Netzwerkprogrammierung 2
D Socket Socket absichtlich so schließen, dass Gegenseite java.net.SocketException: Connection reset wirft Netzwerkprogrammierung 4
J Socket Dateien über Socket auf Server speichern Netzwerkprogrammierung 3
S Socket-Frage zu einem LAN-Spiel. Netzwerkprogrammierung 3
A UDP verlorene Pakete/ socket.receive zu langsam Netzwerkprogrammierung 27
CookieSoft Socket Packet per Socket Netzwerkprogrammierung 8
CookieSoft Fehler bei Socket Netzwerkprogrammierung 4
D Socket Datei nur stückweise über Socket verschicken Netzwerkprogrammierung 6
T Per Socket auf POP3 zugreifen? Netzwerkprogrammierung 7
G Bild über Socket schicken - Client/Server Netzwerkprogrammierung 10
Z Socket Socket-Thread falsch? Netzwerkprogrammierung 5
Helgon Socket Socket IP Frage + Tutorial/Bücher Netzwerkprogrammierung 5
S Socket Verschiedene Exceptions beim Übertragen von Bildern über Socket Netzwerkprogrammierung 20
T Socket String zu Socket Netzwerkprogrammierung 26
M Datenübertragung per Socket nur alle 200ms Netzwerkprogrammierung 4
C Socket Socket: Connection timed out Netzwerkprogrammierung 3
T Socket blockierter Socket Netzwerkprogrammierung 4
C Socket Probleme beim Lesen und Schreiben aus/in einen Socket Netzwerkprogrammierung 2
T Alternative Socket mit Verbindungsabbruch Erkennung Netzwerkprogrammierung 2
M Socket, Ende Dateitransfer Netzwerkprogrammierung 4
X Über eine Socket-Verbindung Arrays übergeben Netzwerkprogrammierung 5
D RMI oder Socket Netzwerkprogrammierung 4
H Socket Socket listening Netzwerkprogrammierung 11
D Client Socket mit Eventlistener? Netzwerkprogrammierung 5
P Socket Verbindung über das Internet Netzwerkprogrammierung 2
A Socket Netzwerkprogrammierung 18
N Socket geht auf Windows, aber auf Mac nicht ? Netzwerkprogrammierung 3
ruffio1978 Telnet über ein socket ansprechen Netzwerkprogrammierung 8
G Exception: Connection reset by peer: socket write error Netzwerkprogrammierung 2
M SSl Socket Server und openssl key Netzwerkprogrammierung 3
J Socket Socket Programmierung. Wie anfangen? Netzwerkprogrammierung 4
DEvent Keine IOException beim schreiben Socket Netzwerkprogrammierung 3

Ähnliche Java Themen

Neue Themen


Oben