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 1067093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:06:33+00:00 2026-05-16T20:06:33+00:00

My server and client are running on the same machine so I dont have

  • 0

My server and client are running on the same machine so I dont have endian issues etc. I need something that works on both vc++ and g++ and possibly the simplest way. What can I send the struct with?

Edit

struct Info
{
     int**   fields; 
     char**  field_names;
};
  • 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-16T20:06:33+00:00Added an answer on May 16, 2026 at 8:06 pm

    You can declare a static unsigned char like so:

    #define MSGBUFSIZE  512
    static unsigned char ClientSendBuf[MSGBUFSIZE];
    

    then copy your structure into the array like so:

    memmove(&ClientSendBuf[2], &struct, sizeof(struct));
    

    now this where it is implementation specific next. I am using Borland C++ so my sending acts like so:

    ClientSocket->Socket->SendBuf(ClientSendBuf, ClientSendBuf[0]+CRC16SIZE);
    

    The reason I use ClientSendBuf[0] is because the size of my message is stored in ClientSendBuf[0] like so:

    ClientSendBuf[0] = 4 + sizeof(struct);             //Byte Count
    

    (Note: Replace struct with the name of your struct)

    I also add a CRC check to the end of my message like so:

    #define CRC16SIZE   2
    

    …

    cs = CheckSum((unsigned char *)ClientSendBuf, ClientSendBuf[0]);
        memmove(&ClientSendBuf[ClientSendBuf[0]], &cs, CRC16SIZE);
    

    …

    unsigned short __fastcall TFormMenu::CheckSum(unsigned char *p, int length)
    {
        int i;
    
        for (cs = 0, i = 0; i < length; i++) {
            cs += p[i];
        }
        return cs;
    }
    

    Basically all this simple CRC check is doing is summing all the bytes to determine that the correct number of bytes is sent. If the data should get mangled (which is common through buggy WiFi connections by the way), then the server should throw a CRC error.

    This all assumes you have a POD struct. The static part is not necessary, but how I did it in my particular application. I also glossed over some details. Post in the comments if you have questions. YMMV.

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

Sidebar

Related Questions

I have a client running a WebLogic 11g install on a Windows Server machine
I have a REST server and a client application running on a mobile device.
I have a somewhat simple Client/Server solution running over C# remoting (System.Runtime.Remoting). The MarshalByRef
My client is running on a Tomcat server and I do not have access
I'm developing a client-server application and have been tasked with adding support for running
I am working on a client server system, and am running into issues where
I've been trying for days now to create an application client server,both on android,running
I have a server, to which a client machine connects. Recently I decided to
I have a Glassfish 3.1.2 server running on a remote machine (JDK 1.6.0_30). The
I'm trying to get a simple socket.io server running: Client: <script src=http://www.my-server.com:8080/socket.io/socket.io.js></script> var socket

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.