Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

TCP Data Handling, problem with .Text

tcp data handling text appendtext no display

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 darrenleesuona

darrenleesuona

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 20 May 2015 - 06:54 PM

I am doing a TCP server & client communication. I would like to display the received data (from client) on the textbox of the server.

When i used txtStatus.AppendText, it works perfectly fine. But when i changed to txtStatus.Text, nothing was shown in the textbox.

I have tried using

txtStatus.Text += recMovementData.BaseMoveData.BaseMov.ToString();
but to no avail. :-(

It should work as it is the same as .AppendText but it doesnt :(

Can anyone help me with this?

This is my code for my server:

private void btnListen_Click(object sender, EventArgs e)
        {
            
            //IPAddress ipaddress = IPAddress.Parse(txtIP1.Text + "." + txtIP2.Text + "." + txtIP3.Text + "." + txtIP4.Text);
            //int portNum = Convert.ToInt32(txtPort.Text);
            IPAddress ipaddress = new IPAddress(new byte[] { 123, 123, 123, 123 });
            int portNum = 8500;
            TCPServerHelper.AcceptConnection(ipaddress, portNum);
            txtStatus.Text = "Connected to remote client!";

            while (true)
            {
                    byte[] bufferReceivedData = TCPServerHelper.Read();
                    MovementData recMovementData = (MovementData)TCPServerHelper.Deserialize(bufferReceivedData);

                    try
                    {
                        //txtStatus.AppendText(recMovementData.BaseMoveData.BaseMov.ToString());
                        txtStatus.Text += recMovementData.BaseMoveData.BaseMov.ToString();
                    }

                    catch
                    { }
             }


#2 ephraimdov

ephraimdov

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 22 June 2015 - 09:29 PM

Check this basic C# Socket Programming

 

Dov






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download