zoukankan      html  css  js  c++  java
  • 网络编程01

    //服务端
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.Net.Sockets;
    
    namespace learn
    {
        class Program
        {
            const int portNo = 500;
    
            static void Main(string[] args)
            {
                IPAddress localAdd = IPAddress.Parse("127.0.0.1");
    
                TcpListener listener = new TcpListener(localAdd, portNo);
                listener.Start();
    
                TcpClient tcpClient = listener.AcceptTcpClient();
    
                NetworkStream ms = tcpClient.GetStream();
                byte[] data = new byte[tcpClient.ReceiveBufferSize];
    
                int numBytesRead = ms.Read(data, 0,System.Convert.ToInt32(tcpClient.ReceiveBufferSize));
    
                Console.WriteLine("Receiced:" + Encoding.ASCII.GetString(data, 0, numBytesRead));
                Console.ReadLine();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Sockets;
    
    namespace Client_CS
    {
        class Program
        {
            const int portNo = 500;
            static void Main(string[] args)
            {
                TcpClient tcpclient = new TcpClient();
    
                tcpclient.Connect("127.0.0.1", portNo);
    
                NetworkStream ns = tcpclient.GetStream();
                byte[] data = Encoding.ASCII.GetBytes("Hello");
    
                ns.Write(data, 0, data.Length);
            }
        }
    }
  • 相关阅读:
    session
    php增删改查,分页
    sql题
    php简单的数据增删改查
    php简单登录注册验证
    js题
    jQHTML(获取内容和属性)
    jQ效果(动画)
    Codeforces Round #460 (Div. 2): D. Substring(DAG+DP+判环)
    POJ 2891 中国剩余定理(不互素)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/4568912.html
Copyright © 2011-2022 走看看