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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:30:50+00:00 2026-06-03T10:30:50+00:00

char newline = ‘\n’; for ( i = 5 ; i < payload_length &&

  • 0
char newline = '\n'; 
for ( i = 5 ; i < payload_length && payload[i] != newline ; i++ )
{
    username[i-5] = payload[i];
    username[i-4] = '\0';
}

This is part of some server code that I CANNOT modify. I’m writing the client side. I’ve tried the following

websocket.send("SEND "+name+"\n"+message);
websocket.send("SEND "+name+"\\n"+message);
websocket.send("SEND "+name+"\r\n"+message);

None work. It doesn’t stop at the newline. If i set newline to ‘|’ and then put in ‘|’ in websocket.send then everything works fine. Any ideas?

  • 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-03T10:30:51+00:00Added an answer on June 3, 2026 at 10:30 am

    You can control in your c code what exactly arrives from the JS side of things by placing

    printf ("chr arrived: %i %c \n", payload[i], payload[i]);
    

    in your loop, which prints the numeric value of the current chr and the chr itself.

    If you check the newline chr:

    char newline = '\n';
    printf ("chr arrived: %i %c \n", newline, newline);
    

    output will be:

    > ./test
    chr arrived: 10
    
    >
    

    I guess what you send in your example are the characters \(92) and n(110) so i would sugest you try the following to specify you newline character in JS:

    var newline = String.fromCharCode(10);
    websocket.send("SEND "+name+newline+message);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

char data_[4096]; ... socket_.async_read_some(boost::asio::buffer(data_, 4096), boost::bind(&client::handle_read_header, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); when function handle_read_header is fired,
With this code: #include <iostream> int main(int argc, char *argv[]) { return 0; }
I'm working with a library that uses Environment.NewLine as it's newline char when writing
I have this code in C which takes in bunch of char s #include<stdio.h>
char str[]=Hello; this allocates 6 bytes for the string , but if i write
I try to replace the char # with a newline \n : sed -e
Is this a safe way to trim the newline character off of a line
On this coderanch link, I found that the following comment will give compiler error
I want to make sure that _content does not end with a NewLine character:
int main() { char **k; char *s =abc; char *b =def; k = &s;

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.