Welcome

首页 / 软件开发 / .NET编程技术 / Socket编程二

Socket编程二2010-08-18 cnblogs panjun-Donet Do-websoftware客户端

using System.Windows.Forms;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Net;//使用IPAredd类,IPHostEntry类
namespace QQ
{
public partial class Tcpclient : Form
{
private StreamWriter write;
private NetworkStream stream;
private TcpClient tcpclient;
public Tcpclient()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
tcpclient = new TcpClient(AddressFamily.InterNetwork);
tcpclient.Connect("127.0.0.1",8000);
stream = tcpclient.GetStream();
write = new StreamWriter(stream);
write.WriteLine(this.textBox1.Text);
write.Flush();
}
catch
{
}
}
}
}