Developing a Chat System

Okay, so I want to develop a chat system much like AIM. I have a few problems: Even though I believe that Java is the best language for something like this, the server I am working on doesn't support it. I can only run PHP and CGI scripts. Is there a way to do this with only PHP or CGI?
Here are a few of my ideas:
Create either a JAVA applet or a JAVA downloaded program that users can use to chat. When they log in, they call a CGI or PHP script that places their username and IP address into a database. They can query the database to see who else is logged in and then create a direct P2P connection using that IP address. Nice? The problems: Can JAVA applets interact that way? If not, it would have to be a JAVA program that is downloaded. The disadvantages of that are obvious. Also, in order to keep a running list of online users, the program would have to query the script constantly. That would severely bog down the server. My only other option is to have users blindly IM users and if they're on, they're on. if not, they're not. That's not user-friendly at all.
What do you guys suggest? I need help on this asap.

Hi threre,
I think that the only "problem" in a P2P chat system is the IP exchange. This is the only reason why a server is needed. You can create the program in java whithout problem. The program will accept the IP somehow and start. This "somehow" will depend on the server. So imho it shouldn't be intergrated in the main program.
Also, an Applet is running on the local computer, so the IP will be the local user's IP. That means there is no problem.
I have no idea about php and cgi, so i can't help you on the IP-exchange system.
CU

Similar Messages

  • Chat System: ConnectException: Connection timed out: connect

    Hi There,
    I am developing a chat system as part of a University project.
    To explain what I have implemented:
    I have three java classes;
    1. Chat Server class which is constantly listening for incoming socket connection on a particular socket:
    while (true)
    Socket client = server.accept ();
    System.out.println ("Accepted from " + client.getInetAddress ());
    ChatHandler c = new ChatHandler (client);
    c.start ();
    2. Chat Handler class uses a thread for each client to handle multiple clients:
    public ChatHandler (Socket s) throws IOException
    this.s = s;
    i = new DataInputStream (new BufferedInputStream (s.getInputStream ()));
    o = new DataOutputStream (new BufferedOutputStream (s.getOutputStream ()));
    public void run ()
    try
    handlers.addElement (this);
    while (true)
    String msg = i.readUTF ();
    broadcast (msg);
    catch (IOException ex)
    ex.printStackTrace ();
    finally
    handlers.removeElement (this);
    try
    s.close ();
    catch (IOException ex)
    ex.printStackTrace();
    protected static void broadcast (String message)
    synchronized (handlers)
    Enumeration e = handlers.elements ();
    while (e.hasMoreElements ())
    ChatHandler c = (ChatHandler) e.nextElement ();
    try
    synchronized (c.o)
    c.o.writeUTF (message);
    c.o.flush ();
    catch (IOException ex)
    c.stop ();
    3. Chat Client class which has a simple GUI and sends messages to the server to be broadcasted to all other clients on the same socket port:
    public ChatClient (String title, InputStream i, OutputStream o)
    super (title);
    this.i = new DataInputStream (new BufferedInputStream (i));
    this.o = new DataOutputStream (new BufferedOutputStream (o));
    setLayout (new BorderLayout ());
    add ("Center", output = new TextArea ());
    output.setEditable (false);
    add ("South", input = new TextField ());
    pack ();
    show ();
    input.requestFocus ();
    listener = new Thread (this);
    listener.start ();
    public void run ()
    try
    while (true)
    String line = i.readUTF ();
    output.appendText (line + "\n");
    catch (IOException ex)
    ex.printStackTrace ();
    finally
    listener = null;
    input.hide ();
    validate ();
    try
    o.close ();
    catch (IOException ex)
    ex.printStackTrace ();
    public boolean handleEvent (Event e)
    if ((e.target == input) && (e.id == Event.ACTION_EVENT)) {
    try {
    o.writeUTF ((String) e.arg);
    o.flush ();
    } catch (IOException ex) {
    ex.printStackTrace();
    listener.stop ();
    input.setText ("");
    return true;
    } else if ((e.target == this) && (e.id == Event.WINDOW_DESTROY)) {
    if (listener != null)
    listener.stop ();
    hide ();
    return true;
    return super.handleEvent (e);
    public static void main (String args[]) throws IOException
    Socket s = new Socket ("192.168.2.3",4449);
    new ChatClient ("Chat test", s.getInputStream (), s.getOutputStream ());
    On testing this simple app on my local host I have launched several instances of ChatClient and they interact perfectly between each other.
    Although when i test this app by launching ChatClient on another machine (using a wi-fi network connection at home), on the other machine that tries to connect to the hosting server (my machine) i get a "connection timed out" on the chatClient machine.
    I have added the port and ip addresses in concern to the exceptions to by-pass the firewall but i am still getting the timeout.
    Any suggestions?
    Thanks!

    Format your code with [ code ] tag pair.
    If you are a young university student I don't understand why current your code uses so many of
    too-too-too old APIs including deprecated ones.
    For example, DataInput/OutputStream should never be used for text I/Os because they aren't
    always reliable.
    Use Writers and Readers in modern Java programming
    Here's a simple and standard chat program example:
    (A few of obsolete APIs from your code remain here, but they are no problem.
    Tested both on localhost and a LAN.)
    /* ChatServer.java */
    import java.io.*;
    import java.util.*;
    import java.net.*;
    public class ChatServer{
      ServerSocket server;
      public ChatServer(){
        try{
          server = new ServerSocket(4449);
          while (true){
            Socket client = server.accept();
            System.out.println("Accepted from " + client.getInetAddress());
            ChatHandler c = new ChatHandler(client);
            c.start ();
        catch (IOException e){
          e.printStackTrace();
      public static void main(String[] args){
        new ChatServer();
    class ChatHandler extends Thread{
      static Vector<ChatHandler> handlers = new Vector<ChatHandler>();
      Socket s;
      BufferedReader i;
      PrintWriter o;
      public ChatHandler(Socket s) throws IOException{
        this.s = s;
        i = new BufferedReader(new InputStreamReader(s.getInputStream()));
        o = new PrintWriter
         (new BufferedWriter(new OutputStreamWriter(s.getOutputStream())));
      public void run(){
        try{
          handlers.addElement(this);
          while (true){
            String msg = i.readLine();
            broadcast(msg);
        catch (IOException ex){
          ex.printStackTrace();
        finally{
          handlers.removeElement(this);
          try{
            s.close();
          catch (IOException e){
            e.printStackTrace();
      protected static void broadcast(String message){
        synchronized (handlers){
          Enumeration e = handlers.elements();
          while (e.hasMoreElements()){
            ChatHandler c = (ChatHandler)(e.nextElement());
            synchronized (c.o){
              c.o.println(message);
              c.o.flush();
    /* ChatClient.java */
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    public class ChatClient extends JFrame implements Runnable{
      Socket socket;
      JTextArea output;
      JTextField input;
      BufferedReader i;
      PrintWriter o;
      Thread listener;
      JButton endButton;
      public ChatClient (String title, Socket s){
        super(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        socket = s;
        try{
          i = new BufferedReader(new InputStreamReader(s.getInputStream()));
          o = new PrintWriter
           (new BufferedWriter(new OutputStreamWriter(s.getOutputStream())));
        catch (IOException ie){
          ie.printStackTrace();
        Container con = getContentPane();
        con.add (output = new JTextArea(), BorderLayout.CENTER);
        output.setEditable(false);
        con.add(input = new JTextField(), BorderLayout.SOUTH);
        con.add(endButton = new JButton("END"), BorderLayout.NORTH);
        input.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            o.println(input.getText());
            o.flush();
            input.setText("");
        endButton.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ev){
            try{
              socket.close();
            catch (IOException ie){
              ie.printStackTrace();
            System.exit(0);
        setBounds(50, 50, 500, 500);
        setVisible(true);
        input.requestFocusInWindow();
        listener = new Thread(this);
        listener.start();
      public void run(){
        try{
          while (true){
            String line = i.readLine();
            output.append(line + "\n");
        catch (IOException ex){
          ex.printStackTrace();
        finally{
          o.close();
      public static void main (String args[]) throws IOException{
        Socket sock = null;
        String addr = "127.0.0.1";
        if (args.length > 0){
          addr = args[0];
        sock = new Socket(addr, 4449);
        new ChatClient("Chat Client", sock);
    }

  • Help me to design a chat system

    hello
    i am trying to develop a chat system to deploy it on the web .but i am facing a lot of difficulty in dessigning the chat server and client.
    i have seen the chat implementation in www.javaword.com article .the client initially establishes connection to the server while sending message the server receiving the message gives an EOFException.
    pls tell me shall i
    1)write the chat server in servelet or in pure java
    2)how to pass the message to the server (IOStream or ServeletIostream
    pls help me .if any of you have done this pls let me know how you have done .
    thanking you
    krishna murthy .u.

    See my Chat.
    http://es.geocities.com/fjsrey/files/IRC/download.htm

  • How can i develop gtalk type chat system

    How can i develop gtalk type chat system. How can i get deep Knowledge about AJAX. Any one can provide an example of AJAX program.

    Bagish wrote:
    How can i develop gtalk type chat system. The easiest way: don't. Find existing chat servers. Google for "Jabber".
    How can i get deep Knowledge about AJAX.Read a book about it, and do exercises.
    Any one can provide an example of AJAX program.Perhaps, but why not get the book? Or just google for "ajax tutorial" for God's sake.

  • Chat System: Layout Issues ?

    Hi there,
    A group of us are currently developing a Multiplayer Monopoly game with a Chat System.
    Within the main menu (JFrame) of the Applet, the chat System is to be drawn on by the main menu calling a JPanel with a width and height parameters. ie:
    DrawChatPanel(int width, int height) The problem is what ever the Parameters are passed in, the Jpanel and all its chat components (TextPane, buttons etc) should be dynamically resized accordingly and still fit to the layout. I have played about with numerous of the Layouts but I am having problems resizing the components.
    Would anyone have any sugestions or faced this problem before?
    Thanks!

    This should answer your questions: [url http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html] Effective Layour Management: Short Course
    One thing to keep in mind is burying Panels with FlowLayout within other Panels that respect Component Preferred size.

  • Need to develop a help system

    I need to develop a help system for a Client-Server Oracle Form Application.
    Can any one suggest any good packages to develop Help system?
    Does any one tried Oracle Help for Java (OHJ)?
    Please let me know your recommendations and opinions, thanks.
    null

    Two methods.
    One generate a HTML file and use the Web.Show_Document to display the help file.
    Two use shareware like 'Help Workshop' which can be found at www.cnet.com.
    Good Luck

  • Double Billing and no help from the Chat System

    For 12 months now I've been billed for 2 accounts. I contacted the chat system about this and I was told that while her terminal couldn't fix it she would have someone else contact me later about canceling the one account without getting penalized for canceling that account early. I was in on the ground floor with the Creative Cloud and got the first 12 months at 30.00. It looks like to me when they bumped me to the 50.00 a month they didn't just change my one account but just created another under my email and started billing me for both.
    "Sharan: This subscription cancellation case will be forwarded and you will receive email within 2-3 business days regarding the same." Is what I was told in case # 0211874112.
    But what I got in an email from Adobe is this.
    "With this response, we believe your issue is resolved and have therefore closed your case 0211874112.  If your support case has not been completed to your satisfaction or you should you need to contact us on this issue again, please reference your case number. You can reopen your case up to 14 days after it has been closed."
    It wasn't closed, nothing is resolved.
    HELP PLEASE! This is getting ridiculous, I'm a small business and I don't need to be blowing my time on trying to get a big company to stop stealing from me.
    Stealing my time and money and this point.
    -Russell

    So far the answer is "we can't do anything wrong, we are Adobe" followed up with "your an idiot and if you keep bothering us we're just going to keep charging you"
    How does such amazing software have such utter failuers in the field of support.

  • How do i develop a chat application using jms over web based

    I want to develop a chat application using jms with mailing,file transfer and audio facilities
    can anyone help me to how to go abt that

    There is a good article from Sun on a simple example of what you want - it could serve as a basis for you.
    http://developer.java.sun.com/developer/technicalArticles/peer/

  • Using Flex to develop a ERP system

    I am trying to use Flex4 to  develop a ERP system. Now i am using Module technology. it's seem some  problem when dynamic loading module. Though I do a force reference  in main application. it works. I dont know why and how it happens.
    our demo site is http://demo.coolerp.com  and our support site is www.coolerp.com
    You can check the demo site http://demo.coolerp.com, it seems a little bit slow at the same time.
    Now we are usng the following arthictecture to implement ERP
    http://www.micsun.com/mainsite/show_list_content.jsp?parentId=1949746407&classId=195080214 8
    Any good idea  or good architecture for cool ERP, please come to me.
    BTW, welcome people knowing ERP or Flex knowledge to join free ERP develoment.
    tomby wu

    Hey Tomby,
    Good to know about your idea. I was thinking on similar line, although my motivation was only 'fun' to do this. However, I have good expertise over other RIA platforms like YUI, jQuery etc. Let me know if I can help you any where. I am available at [email protected]

  • ABAP program developed in one system will it run in another system.

    Hi All,
           I have a very important query.
    I know that SAP 4.7, BW 3.1 and SAP CRM 4.0 have same kenel release SAP Basis 620.(please correct me if I am wrong)
    If Kernel in these systems are same, will an ABAP program developed in one system (say SAP 4.7) also work in another system (say CRM 4) with same kernel.
    This is very important me.
    Please help.
    With Regards
    Amit

    Hi Amit,
    1. If we transport a program from R/3
       to BW or CRM,
       It will work inside BW,CRM
       Bcos the basis/abap layer is always there in such systems.
    2. However, if the program uses some tables/FMs etc,
       which are not there in the Bw/Crm,
       then it may give error. thats all.
    Regards,
    Amit m.

  • Doubts over the Performance in Developing a Chat application

    We are developing a chat application which needs to update the chat content in the database for the duration of the chat (ie.,For the duration of a session).At the same time the page should refresh and show the current content on both ends.In addition to both these, the database tables has to be checked to detect the occurence of a Network error on both sides.
    We have developed it as a Browser based chat and we have used PHP with MySQL. The performance is slow.
    Can anyone give a suggestion as to whether we can develop the chat application completely from the scratch and if we do that which technology should we choose to boost the performance.
    If anyone is not clear about my problem just mail me.I'll explain it in more detail.
    Thanks in Advance

    Hi,
    I just wanted to know these following answers.
    2) Network failure -- Means (either browswer got killed or data did not arrived/Page Not refreshed)
    3) which WebSErver are U using?
    From java, it is very easy to develop chatting application for which you can use applet and servlets for the same (if you consider the performance is the utmost importance)
    Updating to the database should not be done for the duration levels rather should be done at the event levels(data change/keyboards/session -inf changes).
    Im not sure about PHPs running at client but I can suggest you to use two frames .One is for typing and other one is for displaying information which basically gets the staus from the server abt other users in the chat either from the session, which would be driven by other component which is static) .
    Any how, I just put my ideas (Im sure , you know all these things)
    with regards
    Lokesh T.c

  • Transport Web Template, Query from development to productive system

    Hi!
    How can I transport Web Template, Query, workbooks from development to productive system?

    RSA1 ---> Transport Coonection ---> Object Types -
    > Select Web Tempelate ---> Drag to right and group under transport
    Similary do for other objects
    Thanks
    Amit

  • SAP CERTIFIED DEVELOPMENT PROFESSIONAL - ABAP SYSTEM INTERFACES WITH SAP

    Hello Experts
    I am Atush Rohan, I have done my "SAP Certified Development Associate - ABAP with SAP NetWeaver 7.0" on 3rd April 2009.
    I want to appear for "SAP Certified Development Professional - ABAP System Interfaces with SAP NetWeaver 7.0". I have about 3 and half years or experience in SAP ABAP. And I plan to give this certificate exam in the coming 6 months.
    Could you please tell me how i apply for this exam, and whether SAP provides the certificate material for the exam "P_ABAP_SI_70". Waiting for a positive reply.
    Regards
    Atush Rohan
    Edited by: Atush Rohan on Jul 30, 2009 1:21 PM

    hi,
    actually you can find your sid on your certificate itself ... your sid will start with SXX .. ok now along with this you will receive an envelope in which there would be an letter where detalis regarding your sid and password for login access in sap market place will be stated... so you can login with that in server market place.... usually you get this along with the certificate and is being provided by the centres authority...   now if you have not received it so you need to contact your centre and tell them to give it to you... if they dont barged then you can ask them for the concern guy's email .... this guy is the one who receives all the documents relating with your certificate .. now this guy is someone from sap labs banglore ...  also if you have not received your id card so you can mail him or tell your centre authority in that case now usually the centre guys take the matters lightly ...
    ok and as far as your certification exams goes i did search the pearson website they really dont have that professional certification for the abap guys but they do have one for functionals and some other....
    ok now you need to approach yout nearest certification centre in that case and simply ask them that you need to appear for level 2 certification also you can contact the sap labs banglore in that case but i know that they are not responding .....
    so in that matter you tell your centre that you need to schedule the certification they will charge you the certification amount and then will  schedule the date..... yes they can do that.
    hope this will surely help you!!!
    thanks & regards,
    Punit Raval.

  • Designing a chat system

    hi
    im trying to design a chat system that will be used in chat.class and i dont know where to start about learning how to desgin a chat system. i dont need it to use a pop up i would have to run on the main applet any help.. ehh sorry

    eg #1
    http://forum.java.sun.com/thread.jspa?forumID=31&start=0&threadID=287509&range=100

  • Developing a chat server ...

    Dear all
    I am planning to develop a chat server to be used locally in my company. I want the members of this server to be able to connect to thier msn and yahoo messenger contacts.
    Is it possible? How can I do it? detailed explaination, please.
    even give any useful links...
    Best Regards

    do you mean some program like JBuddy Messenger,
    you can try this, it is a good example.
    currently it supports AIM, MSN, ICQ, Yahoo and JBuddy protocol.

Maybe you are looking for

  • Report on Internal order

    Hi We have crated an New Internal order and entered the budgeted / planned figures using the KPF6, When we check the  report s_alr_87013017, s alr87013018 and s_alr_87012993 does not show committed. We need a report showing committed spend, actual sp

  • How can we handle view position in bdc

    can any body tell me how to handle view position in bdc

  • Attempting to copy to the disk "My iPod" failed. An unknown error occurred (-69)

    After restoring my iPod 160G because it had frozen on the Apple logo, it started displaying this message whenever I attempted to resync it to my computer. There are a bunch of different files causing the problem, different each time, and it doesn't s

  • Can't use drag and drop with items

    if I want to drag a drop files the icon or doc keeps attached to the mouse and the program is freezed, os I have to restart for e.g. mail. . If I want to move items I only can copy them and poaste. can anybody help?

  • Market Icon MISSING -help!

    After upgrading to 2.2, the Market icon is missing.  Any ideas on how I can get it back?????