Java client
Jeg kan godt få denne klient til at virke lokalt på pc med serveren kørende, men ikke over netværket fra en anden pc hvad skal jeg gøre ved det/*
* ChatClient.java
*
* Created on 29. april 2001, 19:03
*/
/**
*
* @author lord x
* @version
*/
import java.io.*;
import java.net.*;
public class ChatClient extends java.applet.Applet {
/** Initializes the applet ChatClient */
public void init () {
initComponents ();
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents() {
button1 = new java.awt.Button();
textField1 = new java.awt.TextField();
setLayout(new java.awt.BorderLayout());
button1.setFont(new java.awt.Font (\"Dialog\", 0, 11));
button1.setLabel(\"button1\");
button1.setName(\"button1\");
button1.setBackground(java.awt.Color.lightGray);
button1.setForeground(java.awt.Color.black);
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
}
);
add(button1, java.awt.BorderLayout.CENTER);
textField1.setBackground(java.awt.Color.white);
textField1.setName(\"textfield1\");
textField1.setFont(new java.awt.Font (\"Dialog\", 0, 11));
textField1.setForeground(java.awt.Color.black);
textField1.setText(\"textField1\");
add(textField1, java.awt.BorderLayout.EAST);
}
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
String send = textField1.getText();
System.out.println(send);
sendClientchatMessage(send);
}
public void sendClientchatMessage(String s) {
try {
System.out.println(\"1\");
/* String host;
if (args.length > 0 && args[0] != null) {
host = args[0];
} else {
host = \"localhost\";
}
*/
Socket t = new Socket(\"223.223.223.3\", 8009);
System.out.println(\"2221\");
PrintWriter out
= new PrintWriter(new OutputStreamWriter(t.getOutputStream()));
System.out.println(\"2\");
System.out.println(\"Sending: line \");
out.println(s + \"\\n\");
out.flush();
//out.println(\"BYE\");
System.out.println(\"3\");
} catch (Exception e) {
System.out.println(\"Error: \" + e);
}
}
// Variables declaration - do not modify
private java.awt.Button button1;
private java.awt.TextField textField1;
// End of variables declaration
}
