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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:42:36+00:00 2026-06-18T07:42:36+00:00

I want to send code to the mobile label printer via mobile application. I

  • 0

I want to send code to the mobile label printer via mobile application.
I have to do this with TCP connection.
While tcp connection and printing is OK with the windows desktop application,
It just does nothing with the mobile application.
Once I click the connect button it connects to the printer and sends the text without problem
but the printer does not respond!

Appreciate any suggestion

Here is the code

private static NetworkStream stream;
private static TcpClient client;
if (client == null)
{
    client = new TcpClient();
    int port = int.Parse(strPort);
    client.Connect(server, port);
}
stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream, Encoding.GetEncoding("Windows-1251")); 
writer.AutoFlush = false;
writer.Write(Encoding.GetEncoding("Windows-1251").GetBytes(message).Length); 
writer.Write(message);
writer.Flush();
  • 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-18T07:42:37+00:00Added an answer on June 18, 2026 at 7:42 am

    First thought:
    Is it possible that the printer requires a delimiter between the messages? How does the printer know where the expected length ends and where the actual message begins?

    For example, if the string to print is 12345, how does the printer know from the TCP message 512345 whether to expect 5 characters or 51 or 512, etc.?

    Also I think that it is possible that Encoding.GetEncoding("Windows-1251").GetBytes(message).Length delivers a number different from the number of characters within message, if message is not in encoding Windows-1251.

    What you’d have to do is:

    1. Convert message to a byte array
    2. Determine length from that and send byte array

    Sample:

    // Convert message to byte array in Windows 1251 encoding
    // Get a byte array that contains the length of messageBytes as string
    byte[] messageBytes = Encoding.GetEncoding("Windows-1251").GetBytes(message);
    byte[] messageBytesLengthBuffer = Encoding.UTF8.GetBytes(messageBytes.Length.ToString());
    
    stream = client.GetStream();
    stream.Write(messageBytesLengthBuffer, 0, messageBytesLengthBuffer.Length);
    stream.Write(messageBytes, 0, messageBytes.Length);
    

    Finally (!), you should really look into closing the resources you open up!

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

Sidebar

Related Questions

I want to send an SMS via intent, but when I use this code,
In this web application I want to send an sms to a mobile ann.
I am developing an app using phonegap for Android. I want this mobile application
I' m using this code in my mobile application built with phonegap and jQuery
How can i write code for send SMS with delivery message in Windows Mobile?
I want to send SMS with C# in my Windows Mobile (6.1) and get
I want to send an Android Bitmap to a printer (Mobile Bluetooth Printer Bixolon
Hai i want to send the message via coding is it possible? mobile number=xxx
In my code I want to send two parameters in my data. Name is
i want to send an email to user after he sign-up with code.for ex

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.