求助:请教大家有一段代码
前几天在看到一个代码,一直不确定“public static Connection StartClient”的作用,个人理解是此方法作为Connection类的方法,不知道是否正确,请指教。
public class Client
{
public const int CONNECTTIMEOUT = 10;
public Connection _connection;
public Client()
{
}
public static Connection StartClient(IPAddress ipaddress,int port) {
TcpClient client = new TcpClient();
client.SendTimeout = CONNECTTIMEOUT;
client.ReceiveTimeout = CONNECTTIMEOUT;
client.Connect(ipaddress,port);
return new Connection(client.GetStream());
}
}
------解决方案--------------------public static Connection StartClient就是类client的一个方法,返回一个连接