问题描述
publicstaticvoidSend(Sockethandler,Stringdata){//ConvertthestringdatatobytedatausingASCIIencoding.byte[]byteData=Encoding.ASCII.GetBytes(data);//Beginsendingthedatatotheremotedevice.handler.BeginSend(byteData,0,byteData.Length,0,newAsyncCallback(SendCallback),handler);}privatestaticvoidSendCallback(IAsyncResultar){try{//Retrievethesocketfromthestateobject.Sockethandler=(Socket)ar.AsyncState;//Completesendingthedatatotheremotedevice.intbytesSent=handler.EndSend(ar);handler.Shutdown(SocketShutdown.Both);handler.Close();}catch(Exceptione){Console.WriteLine(e.ToString());}}这是发送的,自己在另一个类里调用send函数发送数据,是新手,才学的
解决方案
解决方案二:
顶,你发这个贴是什么目的?
解决方案三:
是我想发一个字符串给连接的远端,调用send函数
时间: 2024-11-05 20:54:18