示例#1
0
 private void OnReceiveCallBack(IAsyncResult IAR)
 {
     try
     {
         Socket tempSock  = (Socket)IAR.AsyncState;
         int    nReadSize = tempSock.EndReceive(IAR);
         if (nReadSize != 0)
         {
             string message = new UTF8Encoding().GetString(recvBuffer, 0, nReadSize);
             mainW.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate
             {
                 mainW.Message.Text += "\r\n서버로 데이터 수신 : " + message;
             }));
             if (message.StartsWith("O"))
             {
                 ReceiveStudentData(message);
             }
         }
         this.Receive();
     }
     catch (SocketException se)
     {
         if (se.SocketErrorCode == SocketError.ConnectionReset)
         {
             BeginConnect();
         }
     }
 }
示例#2
0
 public string GetRemoteResourceContent(CombinatorResource resource)
 {
     using (var wc = new WebClient())
     {
         var byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
         var content           = new UTF8Encoding(false).GetString(wc.DownloadData(resource.AbsoluteUrl));
         if (content.StartsWith(byteOrderMarkUtf8)) // Stripping "?"s from the beginning of css commments "/*"
         {
             content = content.Remove(0, byteOrderMarkUtf8.Length);
         }
         return(content);
     }
 }