巨石化纤
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.

37 lines
962 B

using System;
using System.Net;
using System.Net.Sockets;
namespace SSWMS.Server
{
public class ClientSocket : BaseSocket
{
public ClientSocket(string ip, int port) : base(null)
{
RemoteIP = ip;
RemotePort = port;
}
public bool Connect(out string sResult)
{
bool bResult = true;
sResult = string.Empty;
try
{
if (_socket == null || !_socket.Connected)
{
Dispose();
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_socket.Connect(IPAddress.Parse(RemoteIP), RemotePort);
}
}
catch (Exception ex)
{
bResult = false;
sResult = ex.Message;
Dispose();
}
return bResult;
}
}
}