You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
817 B
31 lines
817 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
using System.IO;
|
|
|
|
namespace PDAForm.Comm
|
|
{
|
|
public class F_Socket
|
|
{
|
|
public static void Send(string msg)
|
|
{
|
|
string PrintServer = MyAppconfig.GetValue("PrintServer");
|
|
if (PrintServer == "") throw new Exception("未配置打印服务器的IP地址!");
|
|
|
|
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
IPAddress ip = IPAddress.Parse(PrintServer);
|
|
IPEndPoint ipoint = new IPEndPoint(ip, 8001);
|
|
socket.Connect(ipoint);
|
|
|
|
byte[] buffer = Encoding.UTF8.GetBytes(msg);
|
|
socket.Send(buffer);
|
|
socket.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|