You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using demo.ClassHelper.NetOperate;
using System.Net.Sockets;
namespace demo.ExternalDevices
{
class A_NXX
{
public static Socket labelClient;
public static void Init()
{
if (labelClient!=null)
{
return;
}
labelClient = TcpClientHelper.CreateTcpClient();
}
public static bool Connect()
{
Init();
if (GetConnectStatus())
return true;
//else
// Close();
return TcpClientHelper.ConnectToServer(labelClient, GlobalVariable.LabelDeviceIP, GlobalVariable.LabelDevicePort);
}
public static void DisConnect()
{
TcpClientHelper.DisConnectServer(labelClient);
}
public static void Close()
{
TcpClientHelper.Close(labelClient);
}
public static bool GetConnectStatus()
{
if (labelClient != null)
{
return labelClient.Connected;
}
return false;
}
public static bool SendPrintFile(string filePath,int timeout = 0)
{
if (!Connect())
{
return false;
}
return TcpClientHelper.SendFileToServer(labelClient, filePath,timeout);
}
}
}