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

  • SEARCH
  • Home
  • 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 7538009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:00:05+00:00 2026-05-30T07:00:05+00:00

Currently, the client is sending messages like this: Public Function checkMD5(ByVal userID As Integer,

  • 0

Currently, the client is sending messages like this:

Public Function checkMD5(ByVal userID As Integer, ByVal gameID As Integer, ByVal file As String, ByVal fileFull As String) As String
    Dim make As New CMakeMSG
    Dim md5 As New CMD5
    make.append("checkfileMD5")
    make.append(userID)
    make.append(containerID)
    make.append(file)
    make.append(md5.GenerateFileHash(fileFull))

    Return SocketSendAndReceiveMSG(make.makestring)
End Function

The server may receive something like this:

checkfileMD5-MSGDelimit0-12-MSGDelimit1-54-MSGDelimit2-filename.txt-MSGDelimit3-*md5hash*

Which it then reads out:

Private _message As String
Public Function handleMessage() As String
    Dim brokenMessage As New ArrayList
    brokenMessage = breakDown() 'Split to ArrayList

        If brokenMessage(0) = "checkfileMD5" Then
            Try
                If brokenMessage.Count > 5 Then
                    Return "0-structureMessedUp"
                End If
                Return CompareFileMD5(brokenMessage(1), brokenMessage(2), brokenMessage(3), brokenMessage(4))
            Catch ex As Exception
                Return "0-structureMessedUp"
            End Try
        End If
End Function

So what it does is take the received message, and split it to an array using the -MSGDelimit- as a delimiter. So in this case the CompareFileMD5() function would receive 12,54,filename.txt,*md5hash*. And based on that it can return to the client whether or not the MD5 matched.

Sure, it works, but it feels sloppy and code on the server gets really messy.

Here’s the less relevant functions from the above code (doubt it matters, but you never know):

Private Function breakDown() As ArrayList
    Try
        Dim theArray As New ArrayList
        Dim copymsg As String = _message

        Dim counter As Integer = 0
        Do Until Not copymsg.Contains("-MSGDelimit")
            Dim found As String

            found = copymsg.Substring(0, copymsg.IndexOf("-MSGDelimit" & counter & "-"))

            theArray.Add(found)
            copymsg = copymsg.Replace(found & "-MSGDelimit" & counter & "-", "")

            counter += 1
        Loop

        theArray.Add(copymsg)
        Return theArray
    Catch ex As Exception
        Module1.msg(ex.Message)
    End Try
End Function

Private Function CompareFileMD5(ByVal userID As Integer, ByVal gameID As Integer, ByVal filename As String, ByVal source As String) As String
    Try
        Dim tryFindFile As String = Module1.filedatabase.findfile(userID, gameID, filename)

        If Not tryFindFile = "notFound" Then
            Dim fileFull As String = tryFindFile & "\" & filename
            Dim md5 As New CMD5
            If md5.GenerateFileHash(fileFull) = source Then
                Return "Match"
            Else
                Return "NoMatch"
            End If
        Else
            Return "notFound"
        End If
    Catch ex As Exception
        Module1.msg("0")
        Return "0"
    End Try
End Function

So, any advice on how to handle it better/cleaner/more professional?

  • 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-05-30T07:00:06+00:00Added an answer on May 30, 2026 at 7:00 am

    Depending on the application, your current solution may be perfectly fine. There are a couple of things that do stand out a little bit:

    • The “protocol” is a bit heavy in terms of the amount of data sent. The delimiters between the data pieces adds quite a bit of overhead. In the example, it makes up maybe 50% of the payload. In addition, sending all data as text potentially makes the payload larger than absolutely necessary. All of this, though, is not necessarily a problem. If the traffic between the client and server is relatively light, then the extra data on the wire may not be a problem at all. For a request of this size (with or without the relatively high delimiter overhead), the main cost will be round trip costs and would likely change very little by reducing the size of this packet by half. If, though, there are requests with thousands of pieces of data, then reducing the payload size would help.

    • The use of the delimiters as shown is potentially ambiguous depending on the data sent. It is unlikely given the length and format of the delimiters, but it’s something to keep in mind if there ever exists the possibility of having actual data that “looks” like a delimiter.

    Assuming that the example shown is one of many similar protocols, I would be inclined to go a different route. One possibility would be to bundle up the request as a JSON object. There are existing packages available to create and read JSON. One example is Json.NET. JSON has a well-defined structure, it is easy for a human to read and verify, and it can be expanded easily. And depending on the data that you send, it would probably a little more lightweight than the current format. And (maybe the part you are interested in), it would maybe seem more “professional”.

    A couple of additional things that I would do (personal opinion):

    • Possibly add a client version to the data being sent so the server will know if it “recognizes” the request. Start the client version at some value (e.g., 1). If there are updates to the protocol format (e.g., different data, different structure), change the version to 2 in that release of the software. Then the server can look at the version number to see if it recognizes it. If it is the first version of the server and sees version 2, then it can return an error indicating the server needs to be updated. This is not necessary if you can guarantee that the client and server releases are always matched (sometimes this is hard in practice).
    • Use an integer value for the request type instead of a string (‘checkFileMD5’). If there are going to be a large number of request types, the server can dispatch the request a little more efficiently (maybe) based on an integer value.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a simple client/server file synchronization . For this, client and
I'm currently implementing a client application that POST's a file over HTTP and have
I currently have a datasource from a client in the form of XML, this
I have a client that receives messages from a Queue. I currently have a
The problem I have is that the client is sending me a string of
I currently have a client that wants me to 'abstract' out a domain model
I am currently validating a client's HTML Source and I am getting a lot
currently redoing a gallery for a client at www.stagecraft.co.uk/gallery.html but i'm getting problems with
Currently I have database with the following associations: One Client to Many Intakes One
Currently we run our web applications on a thin client browser IE 6 and

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.