Skip to content
This repository has been archived by the owner on Nov 28, 2020. It is now read-only.

Commit

Permalink
Netzwerkschnittstellen werden angezeigt
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrabe committed Apr 21, 2011
1 parent 469462e commit c54d9b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
Expand Up @@ -7,6 +7,7 @@ Features:
-Bei Anmeldung: Abfrage von Server-IP und Benutzernamen
-Statusabfrage (Wer ist gerade online?)
-Flüstern (persönlicher Nachrichtenversand an spezielle Adressanten möglich)
-Server zeigt verfügbare Netzwerk-Schnittstellen an

geplante Features:
-Übersetzungsfunktion
Expand Down
26 changes: 26 additions & 0 deletions src/server.java
Expand Up @@ -21,6 +21,9 @@ public server()
System.err.println("Fehler beim Erzeugen der Sockets: "+e);
System.exit(1);
}

System.out.println("Verfügbare Netzwerkschnittstellen:");
showNIC();

connections = new Vector<connection>();

Expand Down Expand Up @@ -55,6 +58,29 @@ public static void main(String[] args)
new server();
}

public static void showNIC() {
// http://www.informatik-blog.net/2009/01/28/informationen-der-netzwerkkarten-auslesen/
try {
Enumeration<NetworkInterface> interfaceNIC = NetworkInterface.getNetworkInterfaces();
// Alle Schnittstellen durchlaufen
while (interfaceNIC.hasMoreElements()) {
//Elemente abfragen und ausgeben
NetworkInterface n = interfaceNIC.nextElement();
System.out.println(String.format("Netzwerk-Interface: %s (%s)", n.getName(), n.getDisplayName()));
// Adressen abrufen
Enumeration<InetAddress> addresses = n.getInetAddresses();
// Adressen durchlaufen
while (addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement();
System.out.println(String.format("- %s", address.getHostAddress()));
}
System.out.println();
}
} catch (SocketException e) {
e.printStackTrace();
}
}

public void broadcast(String msg, String username)
{
int i;
Expand Down

0 comments on commit c54d9b4

Please sign in to comment.