View Single Post
  #5 (permalink)  
Old 05-28-2008, 11:30 PM
Master Zero Master Zero is offline
Member
 
Join Date: May 2008
Posts: 26
Master Zero is on a distinguished road
Yes I am positive because when the client runs locally, it connects fine to the server. Here is proof of it running locally, the link below is a screenshot of it:

Code:
img294.imageshack.us/img294/1895/clipimage002wl1.jpg
It’s only from the web server that it can not seem to connect from. Here is the client code:

Code:
import java.io.*; import java.awt.*; import java.net.*; import javax.swing.*; import javax.swing.text.*; import java.awt.event.*; import java.applet.Applet; public class ChatClient extends Applet implements ActionListener { /** * */ private static final long serialVersionUID = 1L; // Variables TextField msg; TextArea room; Style color; StyledDocument doc; Panel cPanel; JLabel lblIP; JTextField IP; JButton connect; PrintStream os; DataInputStream is; Socket clientSocket; public void init() { this.setLayout(new BorderLayout()); msg = new TextField(); room = new TextArea("", 5, 50, TextArea.SCROLLBARS_VERTICAL_ONLY); cPanel = new Panel(); lblIP = new JLabel("IP Address:"); IP = new JTextField("127.0.0.1"); IP.setHorizontalAlignment(JTextField.CENTER); connect = new JButton("Connect"); connect.addActionListener(this); cPanel.setLayout(new BorderLayout()); cPanel.add("Center", IP); cPanel.add("West", lblIP); cPanel.add("East", connect); this.add("South", msg); this.add("Center", room); this.add("North", cPanel); } // Sends the text public void sendText(String message) { os.println(message); os.flush(); } // AWT event handler @SuppressWarnings("deprecation") public boolean keyDown(Event evt, int key) { //System.out.println(key); if (key == 10) { room.append(msg.getText() + "\n"); this.sendText(msg.getText()); msg.setText(""); //return true; // ignores the key } return super.keyDown(evt, key); } public void actionPerformed(ActionEvent e) { if (e.toString().split(",")[1].substring(4).equals("Connect")) { try { this.clientSocket = new Socket(IP.getText(), 4000); os = new PrintStream(this.clientSocket.getOutputStream()); is = new DataInputStream(this.clientSocket.getInputStream()); room.append("Connection successful...\n"); Listen listen = new Listen(); new Thread(listen).start(); } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); room.append(e1.getMessage()); System.exit(0); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); room.append(e2.getMessage()); System.exit(0); } } } // This class will be used to implement threading public class Listen implements Runnable { @SuppressWarnings("deprecation") public void run(){ try { room.append("Server --> " + is.readLine() + "\n"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); room.append(e.getMessage()); System.exit(0); } run(); } } }
I am also behind a route, do you think that can be the issue?
Reply With Quote