I have managed to capture the message that is sent from TCP / IP, with the class Listener
, however I have been asked to listen especially to the LPT1 port, since the printers of the company are connected via Ethernet, and send them to the LPT1 port of the printer. I'm looking for information and I can not find anything, the only thing I can think of is installing a printer emulator, but I can not find one.
Printers are Intermec
.
The reason for this is an application (I do not have the source code) it sends an image file and with this, a Label is printed (Quantity, Part Number, etc.), I want to receive that information to be able to use it in an app that I'm developing.
This is the code to receive the TCP message:
class TCPIP
{
TcpClient Client;
TcpListener listener = new TcpListener(9100);
public void IniciarEspiar()
{
listener.Start();
}
public void Mandar()
{
Client = new TcpClient("127.0.0.1", 9100);
StreamWriter writer = new StreamWriter(Client.GetStream());
writer.Write("Prueba para TCP/IP");
writer.Flush();
}
public string Espiar()
{
try
{
string Data="";
if ((listener.Pending() == true))
{
Client = listener.AcceptTcpClient();
StreamReader Reader = new StreamReader(Client.GetStream());
while ((Reader.Peek() > -1))
{
Data += Convert.ToChar(Reader.Read()).ToString();
}
if (!string.IsNullOrEmpty(Data))
{
Attach.Escribir(Data);
return Data;
}
}
}
catch (Exception ex)
{ return ex.ToString(); }
return "";
}
}