Results 1 to 9 of 9
Like Tree2Likes
  • 1 Post By Norm
  • 1 Post By Norm

Thread: Calculations in Server side with client`s data

  1. #1
    thitami is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default 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:
    1. Server
    2. Client
    3. 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?
Reply With Quote Reply With Quote

  • #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default Re: Calculations in Server side with client`s data

    How can I say to the server,
    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.

  • #3
    thitami is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default 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?

  • #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default 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.

  • #5
    thitami is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default 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.

  • #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default 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.
    Fubarable likes this.

  • #7
    thitami is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default 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".

  • #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default 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)
    Fubarable likes this.

  • #9
    thitami is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default Re: Calculations in Server side with client`s data

    OK, I think I am more into the solution now.

    Thank you, Norm!

  • Similar Threads

    1. Replies: 1
      Last Post: 03-20-2010, 07:03 PM
    2. NIO Server: listening on client's side socket
      By carek in forum Networking
      Replies: 1
      Last Post: 12-24-2009, 07:30 AM
    3. How to open a file located in server from client side
      By Malathi in forum Web Frameworks
      Replies: 4
      Last Post: 04-20-2009, 09:10 PM
    4. Replies: 1
      Last Post: 03-27-2009, 10:18 AM
    5. Replies: 2
      Last Post: 10-05-2008, 06:13 PM

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •