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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:39:01+00:00 2026-05-23T00:39:01+00:00

I currently have a basic client/server setup. The server needs to take requests from

  • 0

I currently have a basic client/server setup. The server needs to take requests from client(s) and need to respond to different request message types. An example of client request could be get list of files available, how many other clients are connected to the server, etc.

I would obviously have to figure out a way to determine the type of message from the message received from the sender. I was wondering, if I have a struct defined with necessary data, whehter if I can cast the struct to void*, send it as through send(sockfd, message, length, flags) syscall, and than on the receiver side, cast it back to the struct. This of course assumes that I am running the client and server in a same environment.

For example, if I have the following struct:

struct message {
   enum messageType { GET_FILES, GET_CLINET_NUMBER} messageType,
} 

and use this struct to send the message in following way

struct message msg;
msg.messageType = GET_FILES;
send(server_sockfd, (void*)&msg, sizeof(struct), 0)

and on the receiver,

recv(,msg_buffer);
struct message received = (struct message*)msg_buffer;

Ignoring the minor syntactical issues, can anyone advise if this scheme is possible? If not, is there any other way to pass a message without sending raw char*?

  • 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-23T00:39:02+00:00Added an answer on May 23, 2026 at 12:39 am

    This is perfectly possible. Not recommended, though, because now you’re using the same environment for the client and the server, but you may change in the future, and you’ll have to change this code to be more platform/implementation independent.

    Options? boost::serialization, XML-RPC, even HTTP/REST or any other high-level protocol that suits you, Google Protocol Buffers, CORBA, etc.

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

Sidebar

Related Questions

I'm currently in the process of performance profiling. We have a basic client/server application.
Currently, i have basic C++ and PHP skills. But, i want to switch to
currently i have jdbc code with the following basic stucture: get Connection (do the
Currently, I have some basic code to play a simple tone whenever a button
I am currently learning about basic networking in java. I have been playing around
I have the current basic structure for each domain object that I need to
We currently have a company email server with Exchange, and a bulk email processing
currently I have the a basic jQuery gallery: <ul> <li>IMAGE</li> <li>IMAGE</li> </ul> // with
I'm currently enrolled in a Client/Server Programming class (i.e. Java 2) in college. For
I am currently trying to implement basic speech recognition in AS3. I need this

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.