Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3850946
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:05:15+00:00 2026-05-19T17:05:15+00:00

basically, i made an application on the console that sends and receives information. it

  • 0

basically, i made an application on the console that sends and receives information. it works like a chat (it does work, like i chat, i checked).

now what i did here. i transfered some of the code to a winform, and i struggle to understand how can i make the output received (readLine) be printed on the label and input to be sent by the textfield!!

could you direct me and tell me where my mistakes, and how can i make the chat work?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        TcpClient connection;
        StreamReader sr;
        StreamWriter sw;

        public Form1()
        {
            InitializeComponent();
        }

        private void connectServer()
        {
             connection = new TcpClient("127.0.0.1", 5000);
             sr = new StreamReader(connection.GetStream());
             sw = new StreamWriter(connection.GetStream());
        }

        void button_Click(object sender, EventArgs e)
        {

        }


        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
                sw.WriteLine(richTextBox1.Text);
                sw.Flush();            
        }

        private void label1_Click(object sender, EventArgs e)
        {
            label1.Text = sr.ReadLine();
        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:05:15+00:00Added an answer on May 19, 2026 at 5:05 pm

    So…

    you can chat from where to where? same machine, same network, internet?

    You need to create a service to handle the conversation, a global point for all chats, that gets the message and saves it.

    Then you need to, from each client, hook up to that global point and create a “room” and attach the client as an observable, every time there is a new message in that “room”, all observable clients will be warn of incoming message and update their textbox.

    If you want to avoid a “global point” you can use sockets, though, it might not work if the client is somewhere behind a NAT.

    here is a full application in WCF

    http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flash application that I made and I want to basically take
I have just made my first proper little desktop GUI application that basically wraps
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I made an application that should run constant until I stop it. What it
I made a simple notifier command line application in C#. Basically I use the
Basically, i am trying to determin if an application made for 1.x will run
Is this even possible? basically I have a c++ application which sends packed 32
I have a vertical menu in my system which is basically made of HTML
Basically, I would like a brief explanation of how I can access a SQL
Basically I’ve heard that certain conditions will cause .NET to blow past the finally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.