Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Client-Server Forum discussion

Thu Dec 03, 2009 11:24 am

Hello guys,

I need to make a Client-Server type Forum discussion board. It's very complicated for me because i have never done anything simillar before.And i don't have much time..

Can someone tell me from where to start, is there any finished project of this type? I will be grateful for any help!

:wave:



Re: Client-Server Forum discussion

Fri Dec 04, 2009 12:31 pm

what is Client - Server type forum ?

Re: Client-Server Forum discussion

Fri Dec 04, 2009 9:06 pm

Well, i need to create a program in Java,which will represent Forum discussion board that will work in same way as any other regular forum on the internet (so as this one :-)
So, what I know is that client will have some classes, server also,and client should be able to write topics (and articles in every topic,of course) which will be then stored on the server somehow..
So it will have same functionality as any regular Forum Discussion Board on the internet (but simplified as mush as possible :),

I hope I was clear:)

Re: Client-Server Forum discussion

Sun Dec 06, 2009 4:54 pm

OK guys, here is what i figured for these days:
I know for sure that i will need to have two classes (and some other of course) - Client.java & Server.java

Client.java :
Code:
import java.net.*;
import java.io.*;
public class Client {
  public static void main(String args[]) throws IOException {
   
    Socket clientSocket = new Socket("localhost",1234);  // Open your connection to a server, at port 1234
   

    DataInputStream dis = new DataInputStream(clientSocket.getInputStream()); // for receiveng from server
    DataOutputStream dos = new DataOutputStream( clientSocket.getOutoupStream()); // for sending to server
    String st = new String (dis.readUTF());
    System.out.println(st);
   
// When done, just close the connection and exit
    dis.close();
    s1In.close();
    s1.close();
  }
}


Server.java :
Code:
import java.net.*;
import java.io.*;
public class Server {
  public static void main(String args[]) throws IOException {
   
    ServerSocket serverSocket = new ServerSocket(1234);  // Register service on port 1234
    Socket connectionSocket =serverSocket.accept(); // Wait and accept a connection
    // Get a communication stream associated with the socket
    DataInputStream dis = new DataInputStream(connectionSocket.getInputStream());  /for receiving from client
    DataOutputStream dos = new DataOutputStream( connectionSocket.getOutoupStream()); // for sending to client
    // Send a string!
    dos.writeUTF("Hi there");
    // Close the connection, but not the server socket
    dos.close();
    s1out.close();
    s1.close();
  }
}


So,this is the basic of communication between server and client,
but what next? How to make client to write articles, and how to make server to store that articles?Can i store them in ordinar .txt files? This is important because i suppose that everytime when client connects to server he need to download ALL the topics and articles that are posted before, and so i need to figure out through which algoritm i can do that..

Re: Client-Server Forum discussion

Mon Dec 07, 2009 12:57 am

And example of writing and reading of sockets is here to , Java chat using socket programming .
hello , my friend ,
i think you will need to store the articles in database . Using JDBC . this is better to handle than files in such case. concerning . to be it seems you want to send objects from server to client . why don't you using RMI .

Re: Client-Server Forum discussion

Mon Dec 21, 2009 12:02 am

I will use XML instead of Databases, because i'm not familiar with them at all!

But i'm having one problem:

I made a GUI for client and when i assign action to some button (i want to send a simple sentence to Server) nothing happens!

Here is the most important code:

Code:
   public void Connect(){
      String Adress = getAdressServer().getText();
      
      try {
         
          clientSocket = new Socket(Adress,1234);
          DOS = new DataOutputStream(clientSocket.getOutputStream());
          DIS = new DataInputStream(clientSocket.getInputStream());
         
      } catch (UnknownHostException e) {
         // TODO Auto-generated catch block
      System.out.println("Neispravna adresa servera");
      } catch (IOException e) {
      System.out.println("Neispravan unos");
      }
      
   }


   private JButton getSende() {
      if (POSALJI == null) {
         Send = new JButton();
         Send.setBounds(new Rectangle(351, 197, 136, 28));
         Send.setText("SEND");
         Send.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
               DOS.WriteUTF(getSentence.getText());
            } catch (Exception e1) {
               // TODO Auto-generated catch block
               e1.printStackTrace();
            }
               
            }
         });
      }
      return Send;
   }



I know that code for Server class is working well, because i tested it with some other much simplifed class...

Any help?

Re: Client-Server Forum discussion

Mon Jul 05, 2010 8:19 pm

I like your Client Server Project.
I need a Chat Server project between two System for my summer project. I also want to transfer files or smiley in the same project. So can you help me out.
Please send me java code as soon as possible along with step by step procedure to execute...

Re: Client-Server Forum discussion

Thu Jul 22, 2010 1:13 pm

This project sounds good.
You got nice ideas.
Keep it up!

Re: Client-Server Forum discussion

Fri Sep 24, 2010 4:39 am

I really don't understand what are you talking about??? :think:
Please specify something about your project.
May be i can also help you..... :Coo2:

Post a reply
  Related Posts  to : Client-Server Forum discussion
 client server client     -  
 FTP Server and FTP Client     -  
 client server problem     -  
 UDP server and UDP client (J2SE)     -  
 A Simple Client Server Multicasting     -  
 how to connect client on one machine with server     -  
 RMI EXAMPLE FOR CLIENT SERVER ARCHITECTURE CODE ?????     -  
 Client Server Mobile to PC Application     -  
 need java client/server code     -  
 Java Chat Program with client & Server     -