客户端
using System.Windows.Forms;using System.Net;using System.Threading;using System.Net.Sockets;namespace QQ{ public partial class Socketclient : Form { public Socketclient() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string str = this.textBox1.Text.ToString(); BeginSend(str); } private void BeginSend(string str) { IPAddress serverIp = IPAddress.Parse("127.0.0.1"); IPEndPoint iep = new IPEndPoint(serverIp,8000); byte[] byteMessage; Socket socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); socket.Connect(iep); byteMessage = Encoding.ASCII.GetBytes(str); socket.Send(byteMessage); socket.Shutdown(SocketShutdown.Both); socket.Close(); } }}
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索socket
, using
, system
str
socket编程、java socket编程、c socket编程、python socket编程、android socket编程,以便于您获取更多的相关知识。
时间: 2024-09-15 17:18:33