|
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();
|
|
|
|
|
Once I removed this line, it printed without problem:
writer.Write(Encoding.GetEncoding("Windows-1251").GetBytes(message).Length);
|
|
|
|