954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How To make client-Server application?

I am going to build a desktop software with client-server facility.What are the things i need to do for client-server?
1.Should i make 2 different version of the software?One with database for the server and one for client without database.
2.Or should i have some options in one software inside the code?Like when to install the user will choose client/server option and then the required part will be installed?
Which is the best way?Can anyone give some step by step idea?
Thanks.

Upoma
Newbie Poster
14 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Start with a simple version and add features when you get it working.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

The client and server will probably be quite different programs, with completely different installation requirements, so I would say "keep them separate". The client will probably just be a single jar file, but the server will be a different jar, plus database etc.
Either way, your installer can still ask the user which to install and do whatever is required. There's no reason why the installer and the application(s) should have the same structure.

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Your server program will be installed once/ so distributing a one program with server and client capabilities would be redundant.

Design and distribute your client and server applications seperate.

Tellalca
Posting Whiz in Training
209 posts since Mar 2010
Reputation Points: 29
Solved Threads: 24
 

I have alot of experience with client -> server (and vice versa) operations.

You need to learn how binary works, you also need to learn bitwise operations, for example, writing a 4-byte signed integer (d word) to a buffer:

private byte[] buffer = new byte[4];
	private int bufferOffset;
	
	public void writeDWord(int i) {
		buffer[bufferOffset++] = (byte) (i >> 24);
		buffer[bufferOffset++] = (byte) (i >> 16);
		buffer[bufferOffset++] = (byte) (i >> 8);
		buffer[bufferOffset++] = (byte) i;
	}


Then reading that 4-byte signed integer (d word) from a buffer:

public int readDWord() {
		return ((buffer[bufferOffset++] & 0xff) << 24)
			+ ((buffer[bufferOffset++] & 0xff) << 16)
			+ ((buffer[bufferOffset++] & 0xff) << 8)
			+ (buffer[bufferOffset++] & 0xff);
	}


Depending on the application your making, it'd also be good for you to create a packet sending / receiving system, this makes life easier, and heightens the performance of your application.

Or, you could use an API, such as apache mina.

I'm sorry that I barely answered your question, I just thought this would help you.

Jaydenn
Light Poster
41 posts since Nov 2009
Reputation Points: 10
Solved Threads: 1
 

I have alot of experience with client -> server (and vice versa) operations.

..... Or, you could use an API, such as apache mina.

I'm sorry that I barely answered your question, I just thought this would help you.

No no,It is really very helpful for me.Please keep sharing your ideas with me if possible.Thanks a lot.

Upoma
Newbie Poster
14 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Be careful about Jaydenn's input. People write client server in Java all the time without ever needing to touch binary or bitwise operations, or feeling any need to use software outside the standard Java SE API.

Don't take my word for this, read the official tutorial - just four pages starting at
http://download.oracle.com/javase/tutorial/networking/sockets/index.html

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Please read here:
[snipped blog promotion]

rsnich
Newbie Poster
2 posts since May 2012
Reputation Points: 0
Solved Threads: 0
 

@rsnitch:
This thread is long dead.
If you have a proposal for a good way to do client/server in Java please start your own topic

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

@JamesCherrill:
Thanks, I'll to do it. My proposal is suitabe for Java too.

rsnich
Newbie Poster
2 posts since May 2012
Reputation Points: 0
Solved Threads: 0
 

In a Java forum you will need to explain why it is better than simply using the existing tried and tested Sockets and ObjectOutput/ObjectInput streams in the standard Java API.

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: