解决问题了.class server
{
//3825--我在路由里面开的一个端口指向我台机
private const int portNum = 3825; [STAThread]
static void Main(string[] args)
{
bool done = false;
IPAddress address = IPAddress.Parse("192.168.1.101");
TcpListener listener = new TcpListener(address, portNum);
listener.Start();
while (!done)
{
Console.Write("Waiting for connection...");
TcpClient client = listener.AcceptTcpClient(); Console.WriteLine("Connection accepted.");
NetworkStream ns = client.GetStream(); byte[] byteTime = Encoding.ASCII.GetBytes(DateTime.Now.ToString()); try
{
ns.Write(byteTime, 0, byteTime.Length);
ns.Close();
client.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
} listener.Stop();
} }
{
//3825--我在路由里面开的一个端口指向我台机
private const int portNum = 3825; [STAThread]
static void Main(string[] args)
{
bool done = false;
IPAddress address = IPAddress.Parse("192.168.1.101");
TcpListener listener = new TcpListener(address, portNum);
listener.Start();
while (!done)
{
Console.Write("Waiting for connection...");
TcpClient client = listener.AcceptTcpClient(); Console.WriteLine("Connection accepted.");
NetworkStream ns = client.GetStream(); byte[] byteTime = Encoding.ASCII.GetBytes(DateTime.Now.ToString()); try
{
ns.Write(byteTime, 0, byteTime.Length);
ns.Close();
client.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
} listener.Stop();
} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货