using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Ant.Service.Utility
{
public class SocketClient : Object
{
private TcpClient tcpClient;
public SocketClient()
{
tcpClient = new TcpClient();
tcpClient.Client.Blocking = true;
}
///
/// 连接
///
///
///
public void Connect(string host, int port)
{
tcpClient.Connect(host, port);
}
///
/// 关闭连接
///
public void Disconnect()
{
tcpClient.Close();
}
///
/// 发送数据
///
///
///
public bool SendData(byte[] buffer)
{
var len = tcpClient.Client.Send(buffer, 0, buffer.Length, SocketFlags.None);
return len > 0;
}
}
}