Home  >  Article  >  Database  >  2.1.3发送数据和接收数据

2.1.3发送数据和接收数据

WBOY
WBOYOriginal
2016-06-07 15:24:441068browse

发送数据和接收数据的两种方法 发送数据可以用Socket类的Send方法和NetworkStream类的Write方法 接收数据可以用Socket类的Receive方法和NetworkStream类的Read方法 Socket类的Send方法的原型有如下 public int Send( byte[] buffer) public int Send( byte[]

发送数据和接收数据的两种方法

发送数据可以用Socket类的Send方法和NetworkStream类的Write方法

接收数据可以用Socket类的Receive方法和NetworkStream类的Read方法

 

Socket类的Send方法的原型有如下

        public  int  Send( byte[]   buffer )

        public  int  Send( byte[]   buffer, SocketFlags )

        public  int  Send( byte[]   buffer, int size , SocketFlags )

        public  int  Send( byte[]   buffer, int star, int  end, SocketFlags )

Receive方法和Send方法定义相同;

 

NetworkStrem类的Write方法原型:

       public  override  void  Write( byte[]  buffer,  int offset, int  size )

Read方法和Write方法定义相同。

 

下面是演示代码:

 

 

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn