客户端服务器聊天应用程序 [英] Client Server chat application

查看:101
本文介绍了客户端服务器聊天应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更想知道如何开发一个简单的聊天系统.所以我引用了一个网页说明.
http://csharp.net-informations.com/communications/csharp-chat-c​​lient.htm [^ ]

但是在预览时,我的输出无效. Textbox1没有将用户输入显示为预览.如果您有想法,请解释一下.谢谢

[edit]将我的内容视为纯文本..."选项已禁用-OriginalGriff [/edit]

I prefered to know how to develop a simple chat system. So I refered a web note.
http://csharp.net-informations.com/communications/csharp-chat-client.htm[^]

But as It preview, my output didn''t work. Textbox1 didn''t show the user input as preview. If you have an idea please explain it. Thanks

[edit]"Treat my content as plain text..." option disabled - OriginalGriff[/edit]

推荐答案

来自网上某处的软件,但我遇到了问题,最好的地方是从中获得代码的网站.这不是一个完全无关的站点,而是我从中获得代码的站点.
如果您查看该网站的底部,则有一个邮件发送至"链接-您是否考虑过尝试?
Even I can work out that if I get a piece of software from somewhere on the net and I have a problem with it, the best place to ask is the web site I got the code from. Not a totally unrelated site, the one I got the code from.
If you look at the bottom of that site, there is a "mail to" link - have you considered trying it?


更改为,

< pre lang ="c#"> private void btnSend_Click(对象发送者,EventArgs e)
{
NetworkStream serverStream = clientSocket.GetStream();
byte [] outStream = System.Text.Encoding.ASCII.GetBytes(textBox1.Text +"
change as,

<pre lang="c#">private void btnSend_Click(object sender, EventArgs e)
{
NetworkStream serverStream = clientSocket.GetStream();
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox1.Text+"


");
serverStream.Write(outStream,0,outStream.Length);
serverStream.Flush();

byte [] inStream =新的byte [10025];
serverStream.Read(inStream,0,(int)clientSocket.ReceiveBufferSize);
字符串returndata = System.Text.Encoding.ASCII.GetString(inStream);
//string returndata = Convert.ToString(data);
msg(来自服务器的数据:" + returndata);
}

公共无效消息(字符串消息)
{
txtLog.Text = txtLog.Text + Environment.NewLine +>>" + mesg;
}</pre>
");
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();

byte[] inStream = new byte[10025];
serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
string returndata = System.Text.Encoding.ASCII.GetString(inStream);
//string returndata = Convert.ToString(data);
msg("Data from Server: " + returndata);
}

public void msg(string mesg)
{
txtLog.Text = txtLog.Text + Environment.NewLine + ">>" + mesg;
}</pre>


这篇关于客户端服务器聊天应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆