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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:41:59+00:00 2026-06-01T21:41:59+00:00

I made a client in C#, and I would like to have a server

  • 0

I made a client in C#, and I would like to have a server build under Linux, in C.

I use a prefix with “message” length for every “message”.
I encode it to byte[] array by using BitConverter.GetBytes() (4 bytes array).
After that I send it by

socket.Send(prefix, prefix.Length, 0);

The C server on Linux can’t read the number. It displays a strange character, despite it read 4 bytes.

Linux side looks like

char prefix[4];
int bytes = 0;
bytes = recv(s, prefix, 4, 0);
printf("%s", prefix);

If I encode the number by using Encoding.UTF8.GetBytes(), Linux understands it correctly.

I tested it, and it looks the problem is only when the programs are coded in these 2 different languages.

What’s going on?

  • 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-01T21:42:01+00:00Added an answer on June 1, 2026 at 9:42 pm
    • BitConverter.GetBytes() will give you a binary representation – something that is not a printable character in most cases (try the int 0x20202020, this should give you one or more spaces), but perfect for processing purpouses. You can print it with something like printf("%d",the_int_variable)

    • Encoding.UTF8.GetBytes() will give you s string representation – something, that is nice for printing it to the console, but suboptimal for processing.

    Edit

    After your updated question, change printf("%s", prefix); to printf("%d", prefix); after changing prefix to type int and retry.

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

Sidebar

Related Questions

I'm working on a online quiz client where we use a dedicated custom-made linux
I have made a Java Swing application. Now I would like to make it
I have a client who would like to continue to host their forms with
I have made an client - server example using netty. I have defined handlers
I made server/ client application in WCF. How get count of connected clients? And
I have a client jar made-up using java 1.6 and used enum and other
For several applications I made for my current client I have shared user accounts.
I have made some changes in one perforce client, but haven't submitted them. I
My client is determined to have a page at /nfm&t so I made a
I have made a java project and want to deliver it to a client

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.