コード例 #1
0
ファイル: Form1.cs プロジェクト: hongkha336/Exploding-Kittens
        private void button1_Click(object sender, EventArgs e)
        {
            myObject obj = new myObject();

            obj.Id  = textBox2.Text;
            obj.Str = textBox1.Text;

            byte[] buffer = ObjectToByteArray(obj);
            ns.Write(buffer, 0, buffer.Length);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hongkha336/Exploding-Kittens
        public void ReceiveData(TcpClient client)
        {
            NetworkStream ns = client.GetStream();

            byte[] receivedBytes = new byte[6000];
            int    byte_count;

            while ((byte_count = ns.Read(receivedBytes, 0, receivedBytes.Length)) > 0)
            {
                myObject obj = (myObject)ByteArrayToObject(receivedBytes);
                richTextBox1.Text += '\n' + (obj.Id + " : " + obj.Str);
            }
        }