Results 1 to 9 of 9
- 11-18-2011, 10:17 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
Calculations in Server side with client`s data
Hi there,
new to multithreading distributed programming in Java and I am facing an issue, probably simple
for some of you.
I have created 3 classes:
- Server
- Client
- Thread
The server communicates normally with the client in terms of "Oooh, welcome user","Hi there, server"
but I want to send 2 values as a client to the server to make some calculations with them.
Can you describe me the way, that it could be implemented?
How can I say to the server, that the second reply of the client contains the desirable for the calculations values?
- 11-19-2011, 01:55 AM #2
Re: Calculations in Server side with client`s data
Define your own protocol for communications between client and server. As simple as having the first byte(s) of the message contain a code saying what is in the rest of the message.How can I say to the server,
- 11-19-2011, 01:49 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
Re: Calculations in Server side with client`s data
Thank you for your reply.
Do you mean to define it in a separate class, don`t you?
- 11-19-2011, 01:53 PM #4
Re: Calculations in Server side with client`s data
Not necessarily. Are you asking what a protocol is?
Ask Google or Wikipedia what a communication protocol is.
- 11-19-2011, 02:06 PM #5
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
Re: Calculations in Server side with client`s data
Actually, not.
I have read several examples on the Net, but I have not found something, in which the server does some calculations
in its side, with the client`s data, and particularly in beginner level.
Just some cases like chat, which don`t need calculations, but only to show the message.
- 11-19-2011, 02:32 PM #6
Re: Calculations in Server side with client`s data
What the server does with the data it receives depends on the application. A chat app will show the data. Another app may do some calculations and return a result. Its up to the programmer to write the code that controls what the server does.
You would use a protocol to tell the server what kind of data it is receiving and what it is to do with that data.
If the server always gets the same type of data and is to always do the same thing with the data (like a chat app) then there is no need for a protocol.
Can you give some examples of what the client would send to the server and what the server would do with that data and what the server would return to the client.
Here is a simple example. If the messages contains these three Strings:
ADD 10 100
The server would read ADD and then the 10 and 100, convert the Strings to ints and add the 10 and 100 and return:
SUM 110.
The client would read the two Strings, and see that the second string is the sum of the data that it sent to the server.
- 11-19-2011, 02:41 PM #7
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
Re: Calculations in Server side with client`s data
What I am trying to do is to implement a very simple -lets say,airline- booking system. The server shows the options to the user, and then
the latter sends the message "10, Monday", which means the tenth seat for the next Monday.
The server must take this,check if this seat is available, indeed, and return "Booking Complete" or "Booking Failed".
- 11-19-2011, 03:45 PM #8
Re: Calculations in Server side with client`s data
Then your protocol uses String data in its messages.
In the client's message: The first String is the seat number, the second String is the day.
The server's response is also a String with either "Complete" or "Failed" (The word 'Booking' is redundant)
- 11-19-2011, 03:49 PM #9
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
how to access Ms Access from client side to server side
By arunkumarinfo in forum JDBCReplies: 1Last Post: 03-20-2010, 07:03 PM -
NIO Server: listening on client's side socket
By carek in forum NetworkingReplies: 1Last Post: 12-24-2009, 07:30 AM -
How to open a file located in server from client side
By Malathi in forum Web FrameworksReplies: 4Last Post: 04-20-2009, 09:10 PM -
How can i retain special characters in server side (java) after passing from client
By Malathi in forum Web FrameworksReplies: 1Last Post: 03-27-2009, 10:18 AM -
Copy a .swf file from server side to client using signed applet
By Imoracle in forum Java AppletsReplies: 2Last Post: 10-05-2008, 06:13 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks