0

So I am trying a little bit of network and socket programming, I have created simple client and server java application that will connect and allow users to enter messages and talk to each other.

Next I am trying to create a protocol for a game I am looking to make, the game involves 12 lights that are either on or off, the server will use a protocol to send the client values and depending on these values a certain light will turn on.

Example - 000000000100 will turn on light three

The protocol will work the same way from the client in that a button will be pressed and the string will be sent back to the server, the two strings will be checked if they match and if so the user will get a point.

The trouble I am having is where to begin? I have no major knowledge on creating protocols and looking to be pointed in the right direction.

If I send the binary string between client and server will that be considered a protocol or is there more to it?

2
  • Start by actually setting up a client/server class and sending responses to the server and back to the client... Commented Mar 10, 2015 at 20:45
  • 1
    he did it already @ryekayo try to look at some simple textual protocol... e.g. IRC or smth. Commented Mar 10, 2015 at 20:49

2 Answers 2

1

Really, a protocol is whatever you want it to be.

If you send 000000000100 to a server, and that server understands and responds appropriately, then you have a solid application-level protocol. In the context of your game this may be all your protocol even needs to be, or maybe you need to handle error cases (maybe 000000000100 is an invalid value), this is up to you.

However, you don't need to worry about things such as "did the server even get my message?" because TCP handles that. You probably don't want to get to the depth and complication that is TCP for something like this.

Sign up to request clarification or add additional context in comments.

3 Comments

To clarify the last sentence: you do want to use TCP, you don't want to delve into the details of how TCP works.
Cool thanks for the reply, i was just unsure of the actual specs of a protocol and didnt think it was as easy as that
Yes, as @immibis says, you're still going to use TCP for actually transferring your application-layer data.
1

If you will to create the protocol, this will be too easy, because the rules of the protocol will be established for you, and it depend of the nature of the system.

For example: If the system that you are creating the protocol is a simple chat, in the protocol you need put all data to allows the efective comunication between the server and the client. Example

>AAAA;MSG=BLABLA;TIME=12121212<

Suppose, it is the basic structure of you protocol, where ">" "<" are delimeters of you protocol (very useful), "AAAA" the type of message in case that you had more than one message. "MSG" the message, and "TIME" the time of transmission.

Like you see, you define that you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.