Calculations in Server side with client`s data

Printable View

  • 11-19-2011, 01:55 AM
    Norm
    Re: Calculations in Server side with client`s data
    Quote:

    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.
  • 11-19-2011, 01:49 PM
    thitami
    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
    Norm
    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
    thitami
    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
    Norm
    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
    thitami
    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
    Norm
    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
    thitami
    Re: Calculations in Server side with client`s data
    OK, I think I am more into the solution now.

    Thank you, Norm!