火炏炎焱燚

火炏炎焱燚

统计

留言簿(1)

使用ASP.NET AJAX 1.0框架PreviewGlitz进行网页动画编程

阅读排行榜

评论排行榜

socket

  System.IO.FileStream file = new FileStream("c:/a.txt",System.IO.FileMode.OpenOrCreate);
        byte [] msg= new byte[file.Length];
        file.Read(msg, 0, msg.Length );

     
        System.Net.Sockets.Socket send = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);

        System.Net.IPEndPoint ipendp = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 9999);
       
        send.Connect(ipendp);
        send.Send(msg);

        send.Shutdown(System.Net.Sockets.SocketShutdown.Both);
        send.Close();
//发送端

 System.IO.FileStream file = new FileStream("c:/b.txt", System.IO.FileMode.OpenOrCreate);

        System.Net.Sockets.Socket soclip = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
 System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
     

        System.Net.IPEndPoint ipendp = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 9999);
        soclip.Bind(ipendp);
        soclip.Listen(100);

        System.Net.Sockets.Socket soclipapp = soclip.Accept();

 


        byte[] by = new byte[200];
        string str = "";
        soclipapp.Receive(by);

        file.Write(by, 0, by.Length);//'将数据写到kk.txt中
        file.Close();//'流关

        str = System.Text.Encoding.UTF8.GetString(by);
        soclipapp.Shutdown(System.Net.Sockets.SocketShutdown.Both);
        soclipapp.Close();
       Response.Write(str);
//接受,
//网上搜索,自己整理而来,名字我网了。在此表示谢谢
//运行此代码,建立两个工程。同时运行。这两个项目

posted on 2007-10-27 14:34 火炏炎焱燚 阅读(114) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。