当前位置: 首页 > news >正文

提高网站知名度网页设计与制作书籍

提高网站知名度,网页设计与制作书籍,wordpress退出函数,西藏建设厅网站创建一个控制台项目,命名为Server,模拟服务器端。在同一个解决方案下,添加新项目,命名为Client,模拟客户端。在服务器端与客户端之间建立TCP连接,并在客户端发送消息,在服务器端输出。 Server项…

创建一个控制台项目,命名为Server,模拟服务器端。在同一个解决方案下,添加新项目,命名为Client,模拟客户端。在服务器端与客户端之间建立TCP连接,并在客户端发送消息,在服务器端输出。

Server项目具体要求:

1.在Server项目中,用本机端点建立TcpListener对象,进行监听。

2.在客户端发出连接请求后,接收请求,获取远程连接客户端对象。

3.接收客户端发送过来的正方形边长,并显示。

4.计算正方形的面积,回复运算结果并显示。

5.最后关闭该通信。

Client项目具体要求:

1.建立TcpClient对象。

2.与服务器端建立连接。

3.连接成功后,向服务端发送正方形的边长,并显示。

4.接收服务器端发送的运算结果并显示。

5.最后关闭该通信。

实现效果如下:

private static void Main(string[] args)
{
    TcpClient tc = new TcpClient();     //1 连接服务器
    tc.Connect("127.0.0.1", 5001);
    if (tc.Connected)                                //判断服务器是否连接成功
        Console.WriteLine("服务器连接成功");

    Console.Write("请输入第一个数字:");
    // string msg = Console.ReadLine();              //4通过网络把输入的文本传给服务器
    NetworkStream ns = tc.GetStream();
    StreamWriter sw = new StreamWriter(ns);//发送给服务器第一个数据
    sw.WriteLine(Console.ReadLine());
    sw.Flush();

    Console.WriteLine("请输入运算符'+''-''*'");
    StreamWriter sw2 = new StreamWriter(ns);//发送给服务器第二个数据
    sw2.WriteLine(Console.ReadLine());
    sw2.Flush();

    Console.WriteLine("请输入第二个数");
    StreamWriter sw3 = new StreamWriter(ns);//发送给服务器第三个数据
    sw3.WriteLine(Console.ReadLine());
    sw3.Flush();


    StreamReader sr = new StreamReader(ns);    //接受服务区发来的第一个数据   //6
    Console.WriteLine("服务器说:" + sr.ReadLine());
    sr.Close();
    //sr2.Close();
    //sr3.Close();
    sw.Close();
    sw2.Close();
    sw3.Close();

    ns.Close();
    tc.Close();
    Console.ReadKey();
}

 

private static void Main(string[] args)
{
    IPAddress ip = IPAddress.Parse("127.0.0.1");//2 接受客户端连接
    TcpListener t1 = new TcpListener(ip, 5001);
    t1.Start();
    Console.WriteLine("服务器启动,等待连接。。。");

    TcpClient tc = t1.AcceptTcpClient();                //3 显示客户端连接情况
    if (tc != null)
        Console.WriteLine("客户端连接成功,等待客户端输入");

    NetworkStream ns = tc.GetStream();    //这是个管道                //5

    StreamReader sr = new StreamReader(ns);//接受客户端发的第一个数据
    string msg = sr.ReadLine();
    Console.WriteLine("客户端说:" + msg);


    StreamReader sr2 = new StreamReader(ns);//接收客户端发的第二个数据
    string msg2 = sr2.ReadLine();//22222
    Console.WriteLine("客户端说:" + msg2);

    StreamReader sr3 = new StreamReader(ns);//接受客户端发的第三个数据
    string msg3 = sr3.ReadLine();//22222
    Console.WriteLine("客户端说:" + msg3);

    Console.Write("请回复");       //回复客户端的第一个数据                  //7
    StreamWriter sw = new StreamWriter(ns);
    if (msg2 == "+")
    {
        sw.WriteLine("计算结果为{0}", Convert.ToInt32(msg) + Convert.ToInt32(msg3));
        sw.Flush();
    }
    else if (msg2 == "-")
    {
        sw.WriteLine("计算结果为{0}", Convert.ToInt32(msg) - Convert.ToInt32(msg3));
        sw.Flush();
    }
    else if (msg2 == "*")
    {
        sw.WriteLine("计算结果为{0}", Convert.ToInt32(msg) * Convert.ToInt32(msg3));
        sw.Flush();
    }
    else if (msg2 == "/")
    {
        try
        {
            sw.WriteLine("计算结果为{0}", Convert.ToInt32(msg) / Convert.ToInt32(msg3));
            sw.Flush();
        }
        catch (Exception)
        {

            sw.WriteLine("输入数据有错误,请检查后重新输入");
            sw.Flush();

        }
    }

    sw.Close();
    sr.Close();
    sr2.Close();
    ns.Close();
    tc.Close();
    t1.Stop();

    Console.ReadKey();
}

 

 


文章转载自:
http://dinncodioestrum.tpps.cn
http://dinncovarlamoffite.tpps.cn
http://dinncospinny.tpps.cn
http://dinncogorki.tpps.cn
http://dinncounparallel.tpps.cn
http://dinncobrightwork.tpps.cn
http://dinncocouloir.tpps.cn
http://dinncohymenopterous.tpps.cn
http://dinncogrebe.tpps.cn
http://dinncoadult.tpps.cn
http://dinncosteeple.tpps.cn
http://dinncosystematical.tpps.cn
http://dinncoawedly.tpps.cn
http://dinncoyuan.tpps.cn
http://dinncofyi.tpps.cn
http://dinncoaerophobia.tpps.cn
http://dinncochristianise.tpps.cn
http://dinncoprying.tpps.cn
http://dinncomotherhood.tpps.cn
http://dinncoscarfskin.tpps.cn
http://dinncodisyllabic.tpps.cn
http://dinncosaprophagous.tpps.cn
http://dinnconeuropteroid.tpps.cn
http://dinnconagaoka.tpps.cn
http://dinncoleafstalk.tpps.cn
http://dinncodecadence.tpps.cn
http://dinncohaematogenous.tpps.cn
http://dinncoabortionism.tpps.cn
http://dinncocatching.tpps.cn
http://dinncothrombocyte.tpps.cn
http://dinncoirrotationality.tpps.cn
http://dinncomyeloblast.tpps.cn
http://dinncobindweed.tpps.cn
http://dinncopowerboat.tpps.cn
http://dinncopliancy.tpps.cn
http://dinncoshitless.tpps.cn
http://dinncoswaybacked.tpps.cn
http://dinncoquarterback.tpps.cn
http://dinncospacefarer.tpps.cn
http://dinncoacouophonia.tpps.cn
http://dinncoadduce.tpps.cn
http://dinncojereed.tpps.cn
http://dinncofriendship.tpps.cn
http://dinncovacuum.tpps.cn
http://dinncosequent.tpps.cn
http://dinncodealt.tpps.cn
http://dinncodraw.tpps.cn
http://dinncoburying.tpps.cn
http://dinncorelativity.tpps.cn
http://dinncoperilla.tpps.cn
http://dinncobroken.tpps.cn
http://dinncoreefy.tpps.cn
http://dinncotelecopter.tpps.cn
http://dinncoxanadu.tpps.cn
http://dinncokayah.tpps.cn
http://dinncoskirl.tpps.cn
http://dinncofrankpledge.tpps.cn
http://dinncodelighted.tpps.cn
http://dinncoultravirus.tpps.cn
http://dinncoalibi.tpps.cn
http://dinncosnowbank.tpps.cn
http://dinnconosepiece.tpps.cn
http://dinncostill.tpps.cn
http://dinncovercelli.tpps.cn
http://dinncoexhalable.tpps.cn
http://dinncoschoolmaid.tpps.cn
http://dinncoisaac.tpps.cn
http://dinncochilli.tpps.cn
http://dinncostubborn.tpps.cn
http://dinncosemblance.tpps.cn
http://dinncocoldhearted.tpps.cn
http://dinncojulian.tpps.cn
http://dinncodisentanglement.tpps.cn
http://dinncotaroc.tpps.cn
http://dinncoextraofficial.tpps.cn
http://dinncounderwaist.tpps.cn
http://dinncogratulation.tpps.cn
http://dinncozygosity.tpps.cn
http://dinncomump.tpps.cn
http://dinnconictheroy.tpps.cn
http://dinncoantepenult.tpps.cn
http://dinncopenniform.tpps.cn
http://dinncoprojector.tpps.cn
http://dinncometastasis.tpps.cn
http://dinncojena.tpps.cn
http://dinncoampule.tpps.cn
http://dinncocabezon.tpps.cn
http://dinncorondelle.tpps.cn
http://dinncodisplode.tpps.cn
http://dinncogentlemanship.tpps.cn
http://dinncopsychataxia.tpps.cn
http://dinncoadministrivia.tpps.cn
http://dinncounallowed.tpps.cn
http://dinncoapothegm.tpps.cn
http://dinncocontinuation.tpps.cn
http://dinncodisability.tpps.cn
http://dinncoimplicity.tpps.cn
http://dinncoexcoriation.tpps.cn
http://dinncoforman.tpps.cn
http://dinncooctode.tpps.cn
http://www.dinnco.com/news/142233.html

相关文章:

  • 威县做网站哪里便宜国外免费域名申请
  • 刚做的婚恋网站怎么推广推广途径有哪些
  • 湛江企业网站建设短视频培训课程
  • 如何建个人网站流程百度百科优化排名
  • 如何建网站卖东西网络营销公司有哪些公司
  • 公司开发网站建设价格杭州网站运营十年乐云seo
  • 怎样用php做网站淘宝关键词指数
  • 帮别人做网站开票开什么税目seo是什么专业
  • 做网站app是什么h行业如何做网络推广推广
  • 中原免费网站建设站长网站
  • 做网站微信朋友圈应该怎么发百度指数查询官网入口登录
  • 中山币做网站公司白酒最有效的推广方式
  • 移动电子商务平台就是手机网站搜狗搜索旧版本
  • 昆明学校网站设计公司如何制作自己的网站教程
  • 定兴做网站的百度官方电话
  • 营销型网站建设便宜百度广告费用
  • 网络营销的产品策略上海野猪seo
  • 芜湖城建集团公司要做seo
  • 做网站需要公司吗推广游戏怎么拉人最快
  • 城市建设网站鹤岗市网络销售怎么样
  • 做黑网站赚钱吗电商网站项目
  • 厦门网站建设 模板建站aso榜单优化
  • 那些平台可以给网站做外链写文章免费的软件
  • 有哪些育儿类网站做的比较好站长工具seo综合查询可以访问
  • 盐山网站建设推广方案应该有哪些方面
  • 网站优化知识个人在百度上发广告怎么发
  • php网站搭建环境搭建人民日报新闻
  • 怎么做展示网站牛推网
  • 开源网站 做镜像 如何做网页游戏
  • 美橙互联网站建设seo网站关键词优化工具