/// <summary> /// 发送数据 /// </summary> /// <param name="sendData"></param> /// <param name="receiveDataSize"></param> /// <returns></returns> private byte[] SendData(byte[] sendData, int receiveDataSize) { //准备接收缓冲区 byte[] receiveDate = new byte[receiveDataSize + 11]; if (!socket.IsOpen) { socket.Open(); SocketInit();//发送命令,表明身份 Thread.Sleep(100); } //发送并接收数据 socket.SendData(sendData, ref receiveDate); return(receiveDate); }
private void btnSend_Click(object sender, EventArgs e) { string strMessage = txtSend.Text; client.SendData(strMessage); }