add some doc and jtag controller
This commit is contained in:
@@ -6,61 +6,73 @@ class UDPClientPool
|
||||
{
|
||||
private static IPAddress localhost = IPAddress.Parse("127.0.0.1");
|
||||
|
||||
public static void SendString(IPEndPoint endPoint, string[] stringArray)
|
||||
public static bool SendString(IPEndPoint endPoint, string[] stringArray)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
|
||||
byte[] sendbuf = Encoding.ASCII.GetBytes(stringArray[0]);
|
||||
|
||||
socket.SendTo(sendbuf, endPoint);
|
||||
var sendLen = socket.SendTo(sendbuf, endPoint);
|
||||
if (sendLen == stringArray[0].Length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
public async static void AsyncSendString(IPEndPoint endPoint, string[] stringArray)
|
||||
public async static ValueTask<bool> SendStringAsync(IPEndPoint endPoint, string[] stringArray)
|
||||
{
|
||||
await Task.Run(() => { SendString(endPoint, stringArray); });
|
||||
return await Task.Run(() => { return SendString(endPoint, stringArray); });
|
||||
}
|
||||
|
||||
public static void SendBytes(IPEndPoint endPoint, byte[] buf)
|
||||
public static bool SendBytes(IPEndPoint endPoint, byte[] buf)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
socket.SendTo(buf, endPoint);
|
||||
var sendLen = socket.SendTo(buf, endPoint);
|
||||
if (sendLen == buf.Length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
public async static void AsyncSendBytes(IPEndPoint endPoint, byte[] buf)
|
||||
public async static ValueTask<bool> SendBytesAsync(IPEndPoint endPoint, byte[] buf)
|
||||
{
|
||||
await Task.Run(() => { SendBytes(endPoint, buf); });
|
||||
return await Task.Run(() => { return SendBytes(endPoint, buf); });
|
||||
}
|
||||
|
||||
public static void SendAddrPack(IPEndPoint endPoint, WebProtocol.SendAddrPackage pkg)
|
||||
public static bool SendAddrPack(IPEndPoint endPoint, WebProtocol.SendAddrPackage pkg)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
socket.SendTo(pkg.ToBytes(), endPoint);
|
||||
var sendBytes = pkg.ToBytes();
|
||||
var sendLen = socket.SendTo(sendBytes, endPoint);
|
||||
if (sendLen == sendBytes.Length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
public async static void AsyncSendAddrPack(IPEndPoint endPoint, WebProtocol.SendAddrPackage pkg)
|
||||
public async static ValueTask<bool> SendAddrPackAsync(IPEndPoint endPoint, WebProtocol.SendAddrPackage pkg)
|
||||
{
|
||||
await Task.Run(() => { SendAddrPack(endPoint, pkg); });
|
||||
return await Task.Run(() => { return SendAddrPack(endPoint, pkg); });
|
||||
}
|
||||
|
||||
public static void SendDataPack(IPEndPoint endPoint, WebProtocol.SendDataPackage pkg)
|
||||
public static bool SendDataPack(IPEndPoint endPoint, WebProtocol.SendDataPackage pkg)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
socket.SendTo(pkg.ToBytes(), endPoint);
|
||||
var sendBytes = pkg.ToBytes();
|
||||
var sendLen = socket.SendTo(sendBytes, endPoint);
|
||||
if (sendLen == sendBytes.Length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
public async static void AsyncSendDataPack(IPEndPoint endPoint, WebProtocol.SendDataPackage pkg)
|
||||
public async static ValueTask<bool> SendDataPackAsync(IPEndPoint endPoint, WebProtocol.SendDataPackage pkg)
|
||||
{
|
||||
await Task.Run(() => { SendDataPack(endPoint, pkg); });
|
||||
return await Task.Run(() => { return SendDataPack(endPoint, pkg); });
|
||||
}
|
||||
|
||||
public static void SendLocalHost(int port, string[] stringArray)
|
||||
public static bool SendLocalHost(int port, string[] stringArray)
|
||||
{
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
|
||||
byte[] sendbuf = Encoding.ASCII.GetBytes(stringArray[0]);
|
||||
byte[] sendBytes = Encoding.ASCII.GetBytes(stringArray[0]);
|
||||
IPEndPoint ep = new IPEndPoint(localhost, port);
|
||||
|
||||
socket.SendTo(sendbuf, ep);
|
||||
var sendLen = socket.SendTo(sendBytes, ep);
|
||||
if (sendLen == sendBytes.Length) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
public static void CycleSendLocalHost(int times, int sleepMilliSeconds, int port, string[] stringArray)
|
||||
|
||||
Reference in New Issue
Block a user