Java chat server . . . help!

i do macromedia flash and well i downloaded this chat flash java chat. now i know nothing about java, and i do have the sdk and java runtimes. as well as the program bluej. now the guy eho made this chat talks about putting up a server and modifing ports and the like. heres a link of what it says:
http://guardians_of_vox.tripod.com/readme.txt
now can anyone tell me what to do or what to get, cause i am a total n00b at this.

Do you have any specific problems? What have you done? What is not working?

Similar Messages

  • Need some help on JAVA CHAT SERVER

    i need some info about java chat server. Please any one who have developed give me the details about the logic and process flow.

    Have you read any of these?
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2B%22chat+server%22&col=javaforums

  • Trying to produce a java chat server

    Would like produce a working client/server chat system, as basic as possible but able to listen and talk to each other. Any chat servers how-to examples I've come across never seem to work.
    Would like to understand why applets don't work when I open the web page but do work when I view using the appletviewer. I use Internet Explorer 4 i think, java version 1.3.0_02
    would you understand at least part of this error which appears when I run a chat server
    exception:com.ms.security.SecurityExceptionEx[Client.<int>]:cannot access "194.81.104.26":5660
    (the error is all one line no spaces)
    the following code is one of the programs I've been working on and I receive the above error, appletviewer doesn't work so i think that means something is wrong with the code, client side as the server side works well, it listens etc
    // Client side
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    public class Client extends Panel implements Runnable
    // Components for the visual display of the chat windows
    private TextField tf = new TextField();
    private TextArea ta = new TextArea();
    // The socket connecting us to the server
    private Socket socket;
    // The streams we communicate to the server; these come
    // from the socket
    private DataOutputStream dout;
    private DataInputStream din;
    // Constructor
    public Client( String host,int port ) {
    // Set up the screen
    setLayout( new BorderLayout() );
    add( "North", tf );
    add( "Center", ta );
    // Receive messages when someone types a line
    // and hits return, using an anonymous class as
    // a callback
    tf.addActionListener( new ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    processMessage( e.getActionCommand() );
    // Connect to the server
    try {
    // Initiate the connection
    socket = new Socket( host, port );
    // Recieved a connection
    System.out.println( "connected to "+socket );
    // Create DataInput/Output streams
    din = new DataInputStream( socket.getInputStream() );
    dout = new DataOutputStream( socket.getOutputStream() );
    // Start a background thread for receiving messages
    new Thread( this ).start();
    } catch( IOException ie ) { System.out.println( ie ); }
    // Called when the user types something
    private void processMessage( String message ) {
    try {
    // Send it to the server
    dout.writeUTF( message );
    // Clear out text input field
    tf.setText( "" );
    } catch( IOException ie ) { System.out.println( ie ); }
    // Background thread runs this: show messages from other window
    public void run() {
    try {
    // Receive messages one-by-one, forever
    while (true) {
    // Get the next message
    String message = din.readUTF();
    // Print it to our text window
    ta.append( message+"\n" );
    } catch( IOException ie ) { System.out.println( ie ); }
    // ClientApplet
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    public class ClientApplet extends Applet
    public void init() {
    //String host = getParameter( "host" );
         String host="194.81.104.26";
         //int port = Integer.parseInt( getParameter( "port" ) );
         int port =5660;
    setLayout( new BorderLayout() );
    add( "Center", new Client( host, port ) );
    // server
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Server
    // The ServerSocket is used for accepting new connections
    private ServerSocket ss;
    // A mapping from sockets to DataOutputStreams. This will
    // help us avoid having to create a DataOutputStream each time
    // we want to write to a stream.
    private Hashtable outputStreams = new Hashtable();
    // Constructor and while-accept loop all in one.
    public Server( int port ) throws IOException {
    // listening
    listen( port );
    private void listen( int port ) throws IOException {
    // Create the ServerSocket
    ss = new ServerSocket( port);
    // ServerSocket is listening
    System.out.println( "Listening on "+ss );
    // Keep accepting connections forever
    while (true) {
    // The next incoming connection
    Socket s = ss.accept();
    // Connection
    System.out.println( "Connection from "+s );
    // Create a DataOutputStream for writing data to the
    // other side
    DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
    // Save this stream so we don't need to make it again
    outputStreams.put( s, dout );
    // Create a new thread for this connection, and then forget
    // about it
    new ServerThread( this, s );
    // Get an enumeration of all the OutputStreams, one for each client
    // connected to us
    Enumeration getOutputStreams() {
    return outputStreams.elements();
    // Send a message to all clients (utility routine)
    void sendToAll( String message ) {
    // We synchronise on this because another thread might be
    // calling removeConnection()
    synchronized( outputStreams ) {
    // For each client ...
    for (Enumeration e = getOutputStreams(); e.hasMoreElements(); ) {
    // ... get the output stream ...
    DataOutputStream dout = (DataOutputStream)e.nextElement();
    // ... and send the message
    try {
    dout.writeUTF( message );
    } catch( IOException ie ) { System.out.println( ie ); }
    // Remove a socket, and it's corresponding output stream, from our
    // list. This is usually called by a connection thread that has
    // discovered that the connectin to the client is dead.
    void removeConnection( Socket s ) {
    // Synchronise so sendToAll() is okay while it walks
    // down the list of all output streams
    synchronized( outputStreams ) {
    // Removing connection
    System.out.println( "Removing connection to "+s );
    // Remove it from our hashtable/list
    outputStreams.remove( s );
    // Make sure it's closed
    try {
    s.close();
    } catch( IOException ie ) {
    System.out.println( "Error closing "+s );
    ie.printStackTrace();
    // Main routine
    // Usage: java Server <port>
    static public void main( String args[] ) throws Exception {
    // Get the port # from the command line
    int port = Integer.parseInt( args[0] );
         //int port = 5000;
    // Create a Server object, which will automatically begin
    // accepting connections.
    new Server( port);
    // ServerThread
    import java.io.*;
    import java.net.*;
    public class ServerThread extends Thread
    // The Server that spawned
    private Server server;
    // The Socket connected to our client
    private Socket socket;
    // Constructor.
    public ServerThread( Server server, Socket socket ) {
    // Save the parameters
    this.server = server;
    this.socket = socket;
    // Start up the thread
    start();
    // This runs in a separate thread when start() is called in the
    // constructor.
    public void run() {
    try {
    // Create a DataInputStream for communication; the client
    // is using a DataOutputStream to write to us
    DataInputStream din = new DataInputStream( socket.getInputStream() );
    // Over and over, forever ...
    while (true) {
    // ... read the next message ...
    String message = din.readUTF();
    // ... sending printed to screen ...
    System.out.println( "Sending "+message );
    // ... and have the server send it to all clients
    server.sendToAll( message );
    } catch( EOFException ie ) {
    // This doesn't need an error message
    } catch( IOException ie ) {
    // This needs an error message
    ie.printStackTrace();
    } finally {
    // The connection is closed for one reason or another,
    // so have the server dealing with it
    server.removeConnection( socket );
    <body bgcolor="#FFFFFF">
    <applet code="ClientApplet" width=600 height=400>
    <param name=host value="127.0.0.1">
    <param name=port value="5660">
    [Chat applet]
    </applet>
    </body>

    Hi!
    Go to
    http://www.freecode.com/projects/jchat-java2clientserverchatmodule/
    probably u will het the answer..
    Jove

  • Java Chat, server/client*x

    Hey,
    I'm trying to make a chat and I've made the server and client, and the server can accept several clients. Only; they communicate client-server, and not client-server-client (if you get what I mean) like I want them to, pretty obviously, since its a chat. I'm still very new to this, heres my code anyhow:
    Server
    import java.net.*;
    import java.io.*;
    public class OJChatServer{
         public static void main(String[] args) throws IOException{
              int port=2556;
              boolean listening = true;
              ServerSocket cServerSocket = null;
              try{
                   cServerSocket = new ServerSocket(port);
                   System.out.println("Server started; Waiting for client(s) to connect.");
              } catch(IOException e){
                   System.err.println("Could not listen on port: "+port);
                   System.exit(1);
              while(listening){
                   try{
                        new handleClient(cServerSocket.accept()).start();
                   } catch(IOException e){
                        System.err.println("Accept has failed");
                        System.exit(1);
              cServerSocket.close();
         static class handleClient extends Thread{
              private Socket clientSocket = null;
              private PrintWriter send;
              private BufferedReader recieve;
              private String inputString, outputString;
              private String clientName = "";
              public handleClient(Socket acceptedSocket){
                   //super("handleClient");
                   this.clientSocket = acceptedSocket;
              public void run(){
                   try{
                        recieve = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                        send = new PrintWriter(clientSocket.getOutputStream(), true);
                        inputString = recieve.readLine();
                        clientName = inputString;
                        System.out.println("Client \""+clientName+"\" has connected. ("+clientSocket+")");
                        while(inputString != null){
                             outputString = processInput(inputString);
                        //     outputString = send.readLine();
                             send.println(outputString);
                             if(inputString.equalsIgnoreCase("Quit")||inputString.equalsIgnoreCase("/Quit")) break;
                             inputString = recieve.readLine();
                        System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
                   send.close();
                   recieve.close();
                   clientSocket.close();
                   } catch(IOException e){
                        //e.printStackTrace();
                        System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
              }//run()
              static String processInput(String theInput){
                   String theOutput = "From server. Test";
                   return theOutput;
         }//handleClient
    }//OJChatServer---------------------------------------------------------------------------------------------
    Client
    import java.net.*;
    import java.io.*;
    public class OJChatClient{
         public static void main(String[] args) throws IOException{
              String nickname = "Guest";
              String host = "localhost";
              int port = 2556;
              Socket cClientSocket = null;
              PrintWriter send = null;
              BufferedReader recieve = null;
              BufferedReader stdIn = null;
              String fromServer, fromUser;
              System.out.println("Welcome to Ove's Java Chat!\nFor help and commands type: /help");
              nickname = KeyboardReader.readString("Enter nickname: ");
              System.out.println("Connecting to host...");
              try{
                   cClientSocket = new Socket(host, port);
                   send = new PrintWriter(cClientSocket.getOutputStream(), true);
                   System.out.println("Connection established.");
              } catch(UnknownHostException e){
                   System.err.println("Unknown host: "+host);
                   System.exit(1);
              } catch(IOException e){
                   System.err.println("Couldn't get I/O for connection: "+host+"\nRequested host may not exist or server is not started");
                   System.exit(1);
              send.println(nickname);
              stdIn = new BufferedReader(new InputStreamReader(System.in));
              recieve = new BufferedReader(new InputStreamReader(cClientSocket.getInputStream()));
              while((fromServer = recieve.readLine())!=null){
                   System.out.println("Server: "+fromServer);
                   fromUser = stdIn.readLine();
                   if(fromUser!=null){
                        //System.out.println(nickname+": "+fromUser);
                        send.println(fromUser);
                   if(fromUser.equalsIgnoreCase("Quit")||fromUser.equalsIgnoreCase("/Quit")) break;
              System.out.println("Closing connection...");
              send.close();
              recieve.close();
              stdIn.close();
              cClientSocket.close();
              System.out.println("Connection terminated.");
              System.out.println("Goodbye and happy christmas!");
    }I want to make it graphical too, but I want to make it work like it should, before i tackle trying Swing out. This code isn't completely complete yet, as you can see. It doesn't handle the clients messages correctly yet.
    What I want to know is how i should send a message from a client to all the other Sockets on the server.

    It compiles, but it gives an error when the client connects.
    import java.net.*;
    import java.io.*;
    public class OJChatServer4{
         static Socket[] clientSockets = new Socket[100];
         static int socketCounter = 0;
         public static void main(String[] args) throws IOException{
              int port=2556;
              boolean listening = true;
              ServerSocket cServerSocket = null;
              try{
                   cServerSocket = new ServerSocket(port);
                   System.out.println("Server started; Waiting for client(s) to connect.");
              } catch(IOException e){
                   System.err.println("Could not listen on port: "+port);
                   System.exit(1);
              while(listening){
                   try{
                        clientSockets[socketCounter] = cServerSocket.accept();
                        new handleClient(clientSockets[socketCounter]).start();
                        socketCounter++;
                   } catch(IOException e){
                        System.err.println("Accept has failed");
                        System.exit(1);
              cServerSocket.close();
         static class handleClient extends Thread{
              private Socket clientSocket = null;
              public static PrintWriter send;
              private BufferedReader recieve;
              private String inputString, outputString;
              private String clientName = "";
              public handleClient(Socket acceptedSocket){
                   //super("handleClient");
                   this.clientSocket = acceptedSocket;
              public void run(){
                   try{
                        recieve = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                        send = new PrintWriter(clientSocket.getOutputStream(), true);
                        inputString = recieve.readLine();
                        clientName = inputString;
                        System.out.println("Client \""+clientName+"\" has connected. ("+clientSocket+")");
                        while(inputString != null){
                             //outputString =
                             processInput(inputString);
                        //     outputString = send.readLine();
                             send.println(outputString);
                             if(inputString.equalsIgnoreCase("Quit")||inputString.equalsIgnoreCase("/Quit")) break;
                             inputString = recieve.readLine();
                        System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
                   send.close();
                   recieve.close();
                   clientSocket.close();
                   } catch(IOException e){
                        //e.printStackTrace();
                        System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
              }//run()
              static void processInput(String theInput) throws IOException{
                   //String theOutput = "Test From server.";
                   PrintWriter sendToAll;
                   sendToAll = new PrintWriter(clientSockets[socketCounter].getOutputStream(), true);
                   for(int i=0;i<socketCounter;i++){
                        sendToAll.println(theInput);
                   //return theOutput;
         }//handleClient
    }//OJChatServer

  • Sun Java Messaging Server help.

    I have currently running netsacpe messaging server on solris 7. I want to upgrade or change my mail server now. I am intrested in Sun Java Messaging Server 6.
    Here i have few questions in my mind.
    Will it only install on solaris 10 (linux not) ?
    Can I upgrade my NMS 4.1 and Solaris 7 into to SJMS 6 w / without solaris 10 ?
    If I seprate install it can I able to migrate my old NMS 4.1 into SJMS 6 ?
    And lastly Solaris 10 and SJMS are free or not (without commercial support) ?
    If all things goes in my favour then please point me to the right how-to or docs.
    Thanks for reading.

    Well i have started work on it. Two question more.
    1. Does whole JES is free to use without support or i
    need to purchase any component.No purchase of any kind is needed.
    >
    2. Is it possible to migrate NMS 4.1 directory server
    users by using ldif to this new directory server. Absolutely. It's even documented how to do it.
    check in the 5.2 documentation:
    http://docs.sun.com/app/docs/doc/816-6734-10
    As for anti-spam and anti-virus:
    Our engineers believe that they know how to build an excellent mail system. They make no claim to be experts at creaging spam or virus scanners.
    We do have, however, integration with SpamAssassin (free spam scanning), and it's quite easy to integrate Clam AV anti-virus (also free_.
    Why is our Messaging Server better than other products?
    First, it's the highest performance of all we've been able to test.
    Second, the mail server is extremely stable, and scales to systems holding up to a million mailboxes on a single hose. This reduces your cost of administration.
    Third. the system is higly resistant to crashing to the point you have a lot of downtime.
    Fourth, we go to extreme efforts to never loose a message
    >
    Thanks.

  • Chat Server Help

    I'm developing a chat server and I am handling it with threads. I developed a executable class to handle all and I'm putting all the users in two Hashtables. There are two kinds of users. I need to know how many users do you gurus believe it can support? and how could I make it better. Thanks
    Ivan

    the way you do it is okay and the size of the hashtables is just limited by the space the jvm has and the kind of keys you are using.
    regards

  • Java Chat (Server, Client Socket Connection)

    Assignment:
    The assignment is to deliver two source codes that can run a Server (1) and Clients (2) in order to create a simpel chat program. The server has to wait and check an IP (localhost) + Port, and the client has to connect to that port and create a socket connection. The only thing that should be done is create a new socket connection for each client... and when a client sends a message, the message should be delivered to all clients connected to the server.
    Problem...
    However I can read an edit Java, it's difficult for me to write it. I allready found many turturials about socket connections on the internet, and tried to edit those, but they don't really do what I want unless I really write new shit. Is there a way you guys can help me with this, or that you find a really good website that fits my question?

    According to me ,
    take string variable 'str'
    Take some class ,I think u already taken.....
    Scoket scoket = new Socket(IP,port);
    OutputStream out;
    IInputStream in;
    in = socket.getInputStream();
    out = socket.getOutputStream();
    If sends the msg then use
    out.writeObject(str);
    This line sends data to the other user
    msg resivce from client then use
    str = in.readInput();
    & this str set to the any objects out put .
    Such as TextField.setText(str);
    //Server.class
    import java.io.EOFException;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class Server extends JFrame
              private JTextField enterdField;
              private JTextArea displayArea;
              private ObjectOutputStream output;
              private ObjectInputStream input;
              private ServerSocket server;
              private Socket connection;
              private int counter=1;
              public Server()
                        super("Server");
                        enterdField = new JTextField();
                        enterdField.setEditable(false);
                        enterdField.addActionListener(
                             new ActionListener()
                                       public void actionPerformed(ActionEvent event)
                                                 sendData(event.getActionCommand());
                                                 //System.out.println(event.getActionCommand());
                                                 enterdField.setText("");
                   add(enterdField,BorderLayout.NORTH);
                   displayArea = new JTextArea();
                   add(new JScrollPane(displayArea),BorderLayout.CENTER);
                   setSize(300,150);
                   setVisible(true);
              public void runServer()
                        try
                                  server = new ServerSocket(12345,100);
                                  while(true)
                                            try
                                                      waitForConnection();
                                                      getStreams();
                                                      processConnection();
                                            catch(EOFException eofexception)
                                                      displayMessage("\nServer terminated connection");
                                            finally
                                                      closeConnection();
                                                      counter++;
                        catch(IOException ioException)
                                  ioException.printStackTrace();
              private void waitForConnection() throws IOException
                        displayMessage("Waiting for connection");
                        connection = server.accept();
                        //System.out.println(server.accept());
                        System.out.println(connection.getInetAddress());//Server Address and Hostname.
                        displayMessage("Connection"+counter +"received from :"+connection.getInetAddress().getHostName());
              private void getStreams() throws IOException
                        System.out.println("Start getStream");
                        output = new ObjectOutputStream(connection.getOutputStream());
                        output.flush();
                        input = new ObjectInputStream(connection.getInputStream());
                        displayMessage("\nGot I/O stream\n");
              private void processConnection() throws IOException //Read data from Client for Server.
                        String message="Connection sucessful To Client";
                        sendData(message);
                        int i=0;
                        setTextFieldEditable(true);
                        do
                                  try
                                            message =(String) input.readObject();//For Client
                                            System.out.println("Input from :"+message);//From Client
                                            displayMessage("\n" + message);
                                            System.out.println("\n" + i++);
                                  catch(ClassNotFoundException classnotfoundexception)
                                            displayMessage("\nUnknown object type recived");
                        while(!message.equals("CLIENT>>>TERMINATE"));
              private void closeConnection()
                        displayMessage("\nTeminating connection");
                        setTextFieldEditable(false);
                        try
                                  output.close();
                                  input.close();
                                  connection.close();
                        catch(IOException ioException)
                                  ioException.printStackTrace();
              private void sendData(String message)//Write data to the Client from the Server.
                        try
                                  output.writeObject("SERVER>>>"+message);//For Client side.
                                  System.out.println(message);
                                  output.flush();
                                  displayMessage("\nSERVER>>>"+message);//On server side.
                        catch(IOException ioException)
                                  displayMessage("\nError writing object");
              private void displayMessage(final String messageToDisplay)
                        SwingUtilities.invokeLater(
                             new Runnable()
                                  public void run()
                                            displayArea.append(messageToDisplay);
              private void setTextFieldEditable(final boolean editable)
                        SwingUtilities.invokeLater(
                             new Runnable()
                                  public void run()
                                            enterdField.setEditable(editable);
              public static void main(String q[])
                        Server app = new Server();
                        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        app.runServer();
    //Client.class
    import java.io.EOFException;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class Client extends JFrame
         private JTextField enterField;
         private JTextArea displayArea;
         private ObjectOutputStream output;
         private ObjectInputStream input;
         private String message="";
         private String chatServer;
         private Socket client;
         public Client (String host)
                   super("Client");
                   chatServer=host;
                   enterField = new JTextField();
                   enterField.setEditable(false);
                   enterField.addActionListener(
                        new ActionListener()
                                  public void actionPerformed(ActionEvent event)
                                            sendData(event.getActionCommand());
                                            enterField.setText("");
                        add(enterField,BorderLayout.NORTH);
                        displayArea = new JTextArea();
                        add(new JScrollPane(displayArea),BorderLayout.CENTER);
                        setSize(300,150);
                        setVisible(true);
         public void runclient()
                   try
                             connectToServer();
                             getStreams();
                             processConnection();
                   catch(EOFException eofException)
                             displayMessage("\nClient treminated connection");
                   catch(IOException ioException)
                             ioException.printStackTrace();
                   finally
                             closeConnection();
         private void connectToServer() throws IOException
                   displayMessage("Attempting connection\n");
                   client = new Socket(InetAddress.getByName(chatServer),12345);
                   displayMessage("Connect to:"+client.getInetAddress().getHostName());
         private void getStreams() throws IOException
                   output = new ObjectOutputStream(client.getOutputStream());
                   output.flush();
                   input = new ObjectInputStream(client.getInputStream());
                   //Thread t = new Thread(this,"Thread");
                   //t.start();
                   displayMessage("\nGot I/O stream\n");
         private void processConnection( ) throws IOException
                   setTextFieldEditable(true);
                   do
                             try
                                       message=(String)input.readObject();
                                       displayMessage("\n"+message);
                             catch(ClassNotFoundException classnotfoundexception)
                                       displayMessage("\nUnknown object type received");
                   while(!message.equals("SERVER>>>TERMINATE"));
         private void closeConnection()
                   displayMessage("\n Closing connection");
                   setTextFieldEditable(false);
                   try
                             output.close();
                             input.close();
                             client.close();
                   catch(IOException ioException)
                             ioException.printStackTrace();
         private void sendData(String message)
                   try
                             output.writeObject("CLIENT>>>"+message);
                             //System.out.println(message);
                             output.flush();
                             displayMessage("\nCLIENT>>>"+message);
                   catch(IOException ioException)
                             displayArea.append("\n Error writing object");
         private void displayMessage(final String MessageToDisplay)
                   SwingUtilities.invokeLater(
                        new Runnable()
                                  public void run()
                                            displayArea.append(MessageToDisplay);
         private void setTextFieldEditable(final boolean editable)
                   SwingUtilities.invokeLater(
                        new Runnable()
                                  public void run()
                                            enterField.setEditable(editable);
         public static void main(String q[])
                   Client app;
                   if(q.length==0)
                             app = new Client("127.0.0.1");
                   else
                             app = new Client(q[0]);
                   app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   app.runclient();
    Use this example .....
    Give me reply.My method is correct or not
    All the best

  • NIO Chat Server HELP

    hi, i am new to java nio. i have the following general questions:
    1. how can the server know who all is connected.
    2. in non blocking io mode, can we govern the multiplexing sequence? i mean can we iterate the key to a specific client. if so, how?

    the way you do it is okay and the size of the hashtables is just limited by the space the jvm has and the kind of keys you are using.
    regards

  • Chat Server help... outside IP adress error

    In a program i am working on, whenever i replace the ip address to bind to from InetAddress.getLocalHost(); to InetAdress.getByName(">> REAL OUTSIDE IP IN HERE<<"); and run the program i get these errors...
    exception in acceptNewConnections()
    exception in run()
    What can i do to fix this? some code attached
        private void acceptNewConnections() {
         try {
             SocketChannel clientChannel;
             // since sSockChan is non-blocking, this will return immediately
             // regardless of whether there is a connection available
             while ((clientChannel = sSockChan.accept()) != null) {
              addNewClient(clientChannel);
              log.info("got connection from: " + clientChannel.socket().getInetAddress());
              sendBroadcastMessage("login from: " + clientChannel.socket().getInetAddress(), clientChannel);
              sendMessage(clientChannel, "\n\nWelcome to ChatterBox, there are " +
                       clients.size() + " users online.\n");
              sendMessage(clientChannel, "Type 'quit' to exit.\n");
         catch (IOException ioe) {
             log.warn("error during accept(): ", ioe);
         catch (Exception e) {
             log.error("exception in acceptNewConnections()", e);
        public void run() {
         initServerSocket();
         log.info("ChatterServer running");
         running = true;
         int numReady = 0;
         // block while we wait for a client to connect
         while (running) {
             // check for new client connections
             acceptNewConnections();
             // check for incoming mesgs
             readIncomingMessages();
             // sleep a bit
             try {
              Thread.sleep(100);
             catch (InterruptedException ie) {
        }

    Additional Code....
        private void initServerSocket() {
         try {
             // open a non-blocking server socket channel
             sSockChan = ServerSocketChannel.open();
             sSockChan.configureBlocking(false);
             // bind to localhost on designated port
             InetAddress addr = InetAddress.getByName("You think i'd give my ip address?");
             sSockChan.socket().bind(new InetSocketAddress(addr, PORT));
             // get a selector for multiplexing the client channels
             readSelector = Selector.open();
         catch (Exception e) {
             log.error("error initializing server", e);
        }

  • Java Chat Servers???

    I hope this isn't an inappropriate query for this forum. I'm looking for a Java Chat Server and was told that Sun/Java provides a free, open source implementation but haven't been able to find it. I've also looked at some of the commercial offerings such as Volano and RealChat. Would anyone like to offer advice on the best options?
    Thanks for any help.

    I've coded my own very basic version but it would be
    much cheaper for my company to buy one than to try
    and do a full-blown, commercial-grade, fully
    de-bugged implementation from scratch or demos, for
    me at least ;-)I'm sure it would be cheaper. I'm sure that chat servers are extremely common, too. By the way, where does Java come into your picture? I don't see any benefit to having a chat server that happened to be written in Java.

  • PB With Java Embedded Server! Pls Help

    I'm trying to install the Java Embedded Server Framework and I did it like this! I extracted setup.class into g:\jes2.0. My jdk is installed in "G:\winnt\jdk\bin".
    I add "g:\jes2.0" to my environment variable based on the help file
    "Make sure your CLASSPATH environment variable contains . (the current directory) at the beginning of the list."
    Is this correct?
    Then when I type this in the Command Prompt, this happens :
    G:\>cd jes2.0
    G:\jes2.0>java setup
    Exception in thread "main" java.lang.NullPointerException
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:98)
    at setup.loadOffsetTable(ArchiveClassLoader.java:344)
    at setup.instantiateArchiveReader(ArchiveClassLoader.java:155)
    at setup.<init>(ArchiveClassLoader.java:136)
    at setup.main(ArchiveClassLoader.java:1079)

    [omnigunk],
    May we suggest that you post your question under the topic 'Embedded Server' of "Consumer and Commerce" section. This section is dedicated to discussions on Java Embedded Server and thus you might get the correct audience to assist you with your problem.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developer/support/

  • Help me choose a Java Web Server?

    I'm using Ubuntu 9.x and looking for a Java Web Server. I'm really lost as there are far too many out there and there seems none is the de-facto standard used by large corporations.
    My criteria are:
    - FREE for commercial use (requirement)
    - ease of use for installation and configuration (I'm a beginner)
    - good support from the commercial book industry is a huge plus
    - well integrated with eclipse is a huge plus
    - plenty of documentation and free community support
    - one of the major releases such as Apache Geronimo, GlassFish, JBoss, WebSphere and etc.
    I'm not concerned about major performance issues, but less hardware resource demand is better. I'm on a VPS with 256-512MB RAM.
    Any suggestions? What is the most popular one?
    I'm really lost so any suggestions would be much appreciated.

    Frankly, I'm not clear on differences between application and web server although I read this article. It sounds more like I will need an application server for my intended website with will have similar functionality as Facebook.
    Things I am likely to need are DB connection pooling and clustering since I'm hosting in the cloud.
    However, I have limited experience with a Tomcat and Java EE so I frankly don't know what I need although I have built a web site hosted on Tomcat. I figured with an Application Server I have the option of scaling to my needs without having to migrate. Then again, am I planning too far ahead and that migration isn't really that difficult?
    With that said, are there any case studies of large web sites using Tomcat strictly successfully?

  • Java Chatting hosting and server principles...

    I am developing a chat system for my web site...
    There wiil be three components:
    1. Chat Applet
    2. Chat Server
    3. Client Application(s) - Swing - (my computer)
    The server "chat server" should always be online as long as the web site is being present, though the server will not be on the same machine as the web server.
    Should I use an application server, and do I have to?
    What would your opinions and suggestions and preferences be on this matter?

    You may need to keep the chat server on the same computer as the web server, since applets can only connect to the web server from which they were loaded. Unless you want to mess with applet signing.
    Are firewalls an issue? I.e. can you tell all your customers to open a port in their firewalls to connect to the chat server? In some organizations that can be a showstopper. Consider HTTP-based data transfer. The downside is that it'll require polling by the applet to get new messages from the server. Servlet "/chat/send" where the applet HTTP POSTs to send a message, "/chat/getnew?timestamp=12938901230" to get new messages posted by others, "/chat/setpreference?name=logging&value=yesplease" for setting preferences. Reasonably easily adaptable to a non-applet HTML version also.
    Another trick that gets through most firewalls: run the web server on port 80 (HTTP) and the server on 443 (HTTPS) on the same computer. Ugly but usually works. HTTP with servlets is still easier.
    Re application server: I'd just write a standalone application myself. Open a ServerSocket, get incoming connections, create a thread per connection (or use NIO if you have more than, say, 100 simultaneous connections).

  • Java chat console not appearing

    hi there. please help. i am trying to use java chat console but cannot get it to work. i have tried everthing that the chat site tech asks of me, but still no luck. anyone else had this problem PLEASE let me know how u solved it.
    many thanks

    This isn't really a Java programming question... it's more a "something's disconfigured on someone's computer" question... but, just for fun, here are the things you need to check:
    Does your browser have a Java plug-in installed? Is the version of the Java plug-in compatible with the Java chat version the server is using? Do you have Java enabled in your browser? Do you have this problem with other Java applets from other sites, or only this one?
    I'd recommend upgrading your JVM (or downgrading it, if the site is really that broken), checking your browser settings, and possibly testing with another browser.
    Sincerely,
    Dylan

  • Java chat client behind the proxy or fire wall

    i am developing the chat application useing java.net.*.but i am not able to get connectivity behind the firewall or proxy on the java client.pls help me out

    to guarantee easy to use, no problem chat applet then you will need to have the chat server running on port 80 and the client use http request/response system
    first problem is that the applet will have to have been delivered from port 80 on the same ip# so you will either have to use Servlets or write your own web server with chat facilities
    you will need to maitain persistent/ pseudo persistent http connections for the server to deliver messages to clients, you can assume that a connection will remain open for ~ 5 minutes after a request from the client
    use HTTP/1.1 for reliable Connection: keep-alive and request/response pipelining
    with all that in place your client method is...
    register and send GET /chat <wait for upto 5 mins>
    if there is client activity send POST/chat <wait for upto 5 mins>
    if the above waits timeout send GET/chat <wait for upto 5mins>
    server method...
    accept GET/POST requests from client
    if there is chat to deliver, reply to most recent request from client
    if you recive another request before the previous one's reply is used, send a No Content reply to the previous request

Maybe you are looking for

  • ITunes / Gracenote recognized audio cds on one computer but not another!

    What tha....I was importing purchased retail cds (albeit old ones) on my iMac Intel OS 10.4.11 + iTunes 9.0.2.(25) and Gracenote recognized the artist, album cover & tracks no problem. Then I tried importing the same cds onto our MacBook (Intel) usin

  • User/library folder moved

    The Problem is that my library folder accidentally is moved. Then mac os x made a new Library Folder. The strange think is that i can't move that folder or overwrite it with my original library folder. So how did it move in the first place? How can i

  • Cant install itunes and ipad disabled

    I couldnt open itunes on laptop so uninstalled and tried to reinstall it but didnt work all i get is that it didnt install correctly error 7 windows error 193. Also sons ipad disabled due to him forgetting passcode is there any way to reset it withou

  • Sluggish problem with using an external editor

    Whenever I use an external editor (CS5 now) and also Nik software, when I return to Lightroom with the edited file, the problem occurs if I want to do further editing on the picture back in Lightroom. The resonse when I click on something (contrast,

  • Adjustment Brushes in Lightroom 3.6 have stopped working on my iMac

    I have Lightroom 3.6 loaded on my iMac v10.6 and have been using it continuously for some time.     For the second time in just a few weeks the Adjustment Brushes/Sliders have stopped working correctly, that is there is no noticeable adjustment on my