Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9106077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:15:11+00:00 2026-06-17T02:15:11+00:00

The way my game and server work is like this: I send messages that

  • 0

The way my game and server work is like this:

I send messages that are encoded in a format I created. It starts with ‘p’ followed by an integer for the message length then the message.

ex: p3m15
The message is 3 bytes long. And it corresponds to message 15.
The message is then parsed and so forth.

It is designed for TCP potentially only sending only 1 byte (since TCP only has to send a minimum of 8 bits).

This message protocol I created is extremely lightweight and works great which is why I use it over something like JSON or other ones.

My main concern is, how should the client and the server start talking?

The server expects clients to send messages in my format. The game will always do this.

The problem I ran into was when I tested my server on port 1720. There was BitTorrent traffic and my server was picking it up. This was causing all kinds of random ‘clients’ to connect to my server and sending random garbage.

To ‘solve’ this, I made it so that the first thing a client must send me is the string “Hello Server”.

If the first byte ever sent is != ‘H’ or if they have sent me > 12 bytes and it’s != “Hello Server” then I immediately disconnect them.

This is working great. I’m just wondering if I’m doing something a bit naive or if there are more standard ways to deal with:

-Clients starting communication with server
-Clients passing Hello Server check, but somewhere along the line I get an invalid message. I can assume that my app will never send an invalid message. If it did, it would be a bug. Right now if I detect an invalid message then I disconnect the client.

I noticed BitTorrent was sending ‘!!BitTorrent Protocol’ before each message. Should I do something like that?

Any advice on this and making it safer and more secure would be very helpful.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:15:13+00:00Added an answer on June 17, 2026 at 2:15 am

    perhaps a magic number field embedded in your message.

    struct Message
    {
        ...
        unsigned magic_number = 0xbadbeef3;
        ...
    };
    

    so first thing you do after receive something, is checking whether the magic_number field is 0xbadbeef3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are building a multiplayer game that supports replays. The replays work like this:
So i have this file of 10,000+ lines of messages from a game server,
Is there a way to host a SWF game like Bloons Tower Defense ,
Basically I have written a game plugin that will allow server admins to update
This is my 'game server'. It's nothing serious, I thought this was a nice
I am trying to write a game server that supports multiplayer over a network.
I have an air application that I'd like to turn into a multi-player game.
I'm working on a little client that interfaces with a game server. The server
I am freelancing to a game server company and this game server uses a
It's not the type of game that really need a server to operate. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.