"windows form .net chat application" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "windows form .net chat application" answered properly. Developers are finding an appropriate answer about windows form .net chat application related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like windows form .net chat application. Enter your desired code related query in the search bar and get every piece of information about C# code related question on windows form .net chat application.
windows form .net chat application
using System;
using System.Windows.Forms;
using System.Text;
using System.Net.Sockets ;
using System.Threading;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient();
NetworkStream serverStream = default(NetworkStream);
string readData = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox2.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();
}
private void button2_Click(object sender, EventArgs e)
{
readData = "Conected to Chat Server ...";
msg();
clientSocket.Connect("127.0.0.1", 8888);
serverStream = clientSocket.GetStream();
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox3.Text + "$");
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();
Thread ctThread = new Thread(getMessage);
ctThread.Start();
}
private void getMessage()
{
while (true)
{
serverStream = clientSocket.GetStream();
int buffSize = 0;
byte[] inStream = new byte[10025];
buffSize = clientSocket.ReceiveBufferSize;
serverStream.Read(inStream, 0, buffSize);
string returndata = System.Text.Encoding.ASCII.GetString(inStream);
readData = "" + returndata;
msg();
}
}
private void msg()
{
if (this.InvokeRequired)
this.Invoke(new MethodInvoker(msg));
else
textBox1.Text = textBox1.Text + Environment.NewLine + " >> " + readData;
}
}
}
Source: csharp.net-informations.com
All those coders who are working on the C# based application and are stuck on windows form .net chat application can get a collection of related answers to their query. Programmers need to enter their query on windows form .net chat application related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about windows form .net chat application for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of windows form .net chat application while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "windows form .net chat application". Visit this developer's friendly online web community, CodeProZone, and get your queries like windows form .net chat application resolved professionally and stay updated to the latest C# updates.