please i can someone help me about creating chat massager application, please if anyone one know it please help. thanks

1. Do not hijack old threads by posting a new question as a reply to an old one (post already moved to new thread)
2. Learn some spelling
3. Here is your chat "massanger" application
4. You may also want to read this

Edited 6 Years Ago by peter_budo: n/a

Comments
Loved your link to the chat messenger search!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package java_chat_me;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author anthonydonx
 */
public class s {
  int PORT = 3304;
		InputStream inStream;
		DataInputStream inDataStream;
		OutputStream outStream;
		DataOutputStream outDataStream;
		String message="";
		String received="";

 public void re(JTextArea chat_s_area, JTextField chat_s_textwriter) {
       try {

            ServerSocket sock = new ServerSocket(PORT);
		Socket conn = sock.accept();

		inStream = conn.getInputStream ();
		inDataStream = new DataInputStream ( inStream );
		message = inDataStream.readUTF();
               chat_s_area.append(message);
//conn.close();
               } catch (Exception e) {
        }
    }

    void se(JTextArea chat_s_area, JTextField chat_s_textwriter) {



//          try {
//           InetAddress host = InetAddress.getLocalHost();
//		String diffHost = "10.215.183.1";
//		Socket sock = new Socket(diffHost,PORT);
//
//
//                        message = chat_s_textwriter.getText();
//			outStream = sock.getOutputStream();
//			outDataStream = new DataOutputStream (outStream);
//			outDataStream.writeUTF(message);
//
//
//
//
//        } catch (Exception e) {
//        }
        try {
            ServerSocket sock = new ServerSocket(PORT);
		Socket conn = sock.accept();
        inStream = conn.getInputStream ();
		message = chat_s_textwriter.getText();
		outStream = conn.getOutputStream();
		outDataStream = new DataOutputStream (outStream);
//		System.out.println("Enter your message here: ");
		//outDataStream.writeUTF(message);
                chat_s_area.append(message);
    
        } catch (Exception e) {
        }

    }}

client

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package java_chat_me;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author anthonydonx
 */
public class c {
       int PORT = 3304;
		InputStream inStream;
		DataInputStream inDataStream;
		OutputStream outStream;
		DataOutputStream outDataStream;
		String message = "";


    public void conne(JTextArea area,JTextField write){

          try {
              InetAddress thisIp =InetAddress.getLocalHost();
    
           InetAddress host = InetAddress.getLocalHost();
		String diffHost = thisIp.getHostAddress();
		Socket sock = new Socket(diffHost,PORT);

		
                        message = write.getText();
			outStream = sock.getOutputStream();
			outDataStream = new DataOutputStream (outStream);
			outDataStream.writeUTF(message);

	


        } catch (Exception e) {
        }
    }

    void re(JTextArea c_text_box, JTextField c_text_writer) {
         try {

            ServerSocket sock = new ServerSocket(PORT);
		Socket conn = sock.accept();

		inStream = conn.getInputStream ();
		inDataStream = new DataInputStream ( inStream );
		message = inDataStream.readUTF();
               c_text_box.append(message);
             //  conn.close();

               } catch (Exception e) {
        }
    }

}

Edited 6 Years Ago by peter_budo: Adding code tags to second class

This article has been dead for over six months. Start a new discussion instead.