public void ProcessTcpRequest4(object Context) { Socket client = null; try { client = (Socket)Context; PhonePcCommunication.RcvFileFromClient(client); client.Shutdown(SocketShutdown.Both); } catch (SocketException e) { LogHelper.WriteLog(typeof(NetFindfTransfer), e); } finally { if (client != null) { client.Close(); client = null; } } }
public void SendPrintsThread(Object o) { this.mFileSendSuccess = false; this.mFileSendAbort = false; //取消发送置位 终止发送 if (mFileSendEsc == true) { return; } else { try { String filepath = (String)o; this.mSocketClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); PhonePcCommunication.SendFile2Save(this.mSocketClient, filepath, this.mAddress, this.mPort); this.mFileSendSuccess = true;//发送成功 } catch (Exception e) { this.mFileSendAbort = true;//故障终止 Debug.Write(e.Message); return; } finally { if (this.mSocketClient != null) { this.mSocketClient.Close(); this.mSocketClient = null; } } } }