C#中异步TCP的包损坏

时间:2018-05-23 14:06:08

标签: c# asynchronous network-programming tcpclient

我在这里有点酸辣。有一段时间,我试图了解异步TCP的错误。

我在网络上有两台机器从A发送数据 - > B.在发送之前和接收之后,我在两台机器上计算并打印 //import com.ctl.dvar.customermgmt.transformer.request.helper.VCSRRequestHelper; if(commReqBean != null ){ String rcrInvId = commReqBean.getRCRInvariantId(); if(rcrInvId != null && rcrInvId.startsWith("QRP") && commReqBean.getBtnRCR != null && commReqBean.getBtnRCR.length() == 10){ } else if( btnCustCode == null || btnCustCode.length() < 13) { errorCode = "DVAR-CINS-0500" errorMesg = "BTN-CUSTCODE is invalid " + btnCustCode commResBean.setErrorCode(errorCode) commResBean.setErrorMesg(errorMesg) return; } } vccrReqHelper = new com.ctl.dvar.customermgmt.transformer.request.helper.VCSRRequestHelper(); vcsrReqBean = vccrReqHelper.createVCSRRequestBean(commReqBean); 的MD5。

有时候,大约3秒钟,收到邮件的机器会收到损坏的包(不同的MD5)。如果我在localhost上运行这两个程序,则不会发生这种情况。

据我所知,这不应该发生在TCP中,因为它确保了交付和包的完整性(对吗?)。发送代码只是一个while循环,暂时在其中进行休眠。

这是接收端:

        package com.ctl.dvar.customermgmt.services.beans.customerinformation;

    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.List;

    import com.ctl.dvar.common.transformer.beans.CustomerRequestBean;

    public class CustomerCommonRequestBean implements Serializable,
            CustomerRequestBean {
        final public static String COMPOSITE_VIEW_PROCESS = "CompositeViewProcess";
        final public static String CUSTOMER_INFORMATION_PROCESS = "CustomerInformationProcess";
        final public static String CUSTOMER_PRODUCT_INFORMATION_PROCESS = "CustomerProductInformationProcess";
        private static final long serialVersionUID = 1L;

        private String productType;
        private String productId;
        private String ban;
        private String baid;

        private String sourceSystem;

        private String requestType;

        private boolean pendingChangesInd = false;
        private String assocProdInd;
        private String svcAddrLimiter;
        private String productLimiter;
        private int lineLimiter;
        private boolean dupDataCallNotRequired = false;

        private String compositeViewRequestType; // ACCT, PRDT
        private String btnCustCode;
        private String correlationId;

        private boolean callVCSR;
        private boolean callCBI;
        private boolean callRCR;
        private boolean callSR;
        private boolean callRTQ;
        private boolean callCPLUS;
        private boolean callEPWF;
        private boolean callEnsemble;
        private boolean callDupData;
        private boolean callPPP;
        private boolean callDVARCDS;
        private boolean callQCCTLID;
        private boolean includeRCR;// jjena
        private boolean isOCNAllowed = false;
        //US231522
        private boolean isOrderTypeAllowed = false;
        private boolean callRestCDS;

        //US222020 starts
        public boolean isCallRestCDS() {
            return callRestCDS;
        }

        public void setCallRestCDS(boolean callRestCDS) {
            this.callRestCDS = callRestCDS;
        }// ends US222020

        //US228411
        private boolean remarkInfo = false;

        public boolean isRemarkInfo() {
            return remarkInfo;
        }

        public void setRemarkInfo(boolean remarkInfo) {
            this.remarkInfo = remarkInfo;
        }

        //end US228411

        // private boolean callUBB;
        // public boolean isCallUBB() {
        // return callUBB;
        // }
        //
        // public void setCallUBB(boolean callUBB) {
        // this.callUBB = callUBB;
        // }



        public boolean getIncludeRCR() {
            return includeRCR;
        }

        public void setIncludeRCR(boolean includeRCR) {
            this.includeRCR = includeRCR;
        }

        private List<String> authorizedData = new ArrayList<String>();

        private String firstName;
        private String lastName;
        private String stateOrProvince;
        private String zipCode;

        private String wtn;

        private String accountNumber;
        private String serviceOrderNumber;
        private String RCRInvariantId;
        private String serviceType;

        private String userId;
        private String password;
        private String msgSourceSystem;

        private boolean hierarchyCalloutFlag;
        private BigDecimal majorVersionNumber;
        private BigDecimal minorVersionNumber;

        private Calendar sendTimeStamp;
        private String inputChannelId;
        private String srcApplicationId;
        private String srcSystemTranId;
        private String billingApplicationId;

        private boolean requestAccepted = false;

        ArrayList<String> errCode = new ArrayList<String>();
        ArrayList<String> errMesg = new ArrayList<String>();

        boolean acctRequired = false;
        boolean prdtRequired = false;
        private String cspReqType;
        private String requestPurpose;
        private String btnRCR;
        // PLAID_AP2 condition ccv MAy release
        private boolean compositeViewRequest = false;
        // For Perf Logging
        private String accountKey;
        private String clientAuthenticationId;
        private String serviceId;
        private boolean callMqecss;

        private boolean myaBillingAndPaymentSection = false;

        // CR 5399 Aug 2015 R12
        private boolean singleProductIdInfo = false;

        public boolean isCallMqecss() {
            return callMqecss;
        }

        public void setCallMqecss(boolean callMqecss) {
            this.callMqecss = callMqecss;
        }

        public String getServiceId() {
            return serviceId;
        }

        public void setServiceId(String serviceId) {
            this.serviceId = serviceId;
        }

        public String getClientAuthenticationId() {
            return clientAuthenticationId;
        }

        public void setClientAuthenticationId(String clientAuthenticationId) {
            this.clientAuthenticationId = clientAuthenticationId;
        }

        public String getAccountKey() {
            return accountKey;
        }

        public void setAccountKey(String accountKey) {
            this.accountKey = accountKey;
        }

        public String getBtnRCR() {
            return btnRCR;
        }

        public void setBtnRCR(String btnRCR) {
            this.btnRCR = btnRCR;
        }

        public boolean isCompositeViewRequest() {
            return compositeViewRequest;
        }

        public String getRequestPurpose() {
            return requestPurpose;
        }

        public void setRequestPurpose(String requestPurpose) {
            this.requestPurpose = requestPurpose;
        }

        public CustomerCommonRequestBean() {
            super();
            // TODO Auto-generated constructor stub
        }

        public String getBillingApplicationId() {
            return billingApplicationId;
        }

        public void setBillingApplicationId(String billingApplicationId) {
            this.billingApplicationId = billingApplicationId;
        }

        public String getSrcSystemTranId() {
            return srcSystemTranId;
        }

        public void setSrcSystemTranId(String srcSystemTranId) {
            this.srcSystemTranId = srcSystemTranId;
        }

        public String getSrcApplicationId() {
            return srcApplicationId;
        }

        public void setSrcApplicationId(String srcApplicationId) {
            this.srcApplicationId = srcApplicationId;
        }

        public Calendar getSendTimeStamp() {
            return sendTimeStamp;
        }

        public void setSendTimeStamp(Calendar sendTimeStamp) {
            this.sendTimeStamp = sendTimeStamp;
        }

        public String getInputChannelId() {
            return inputChannelId;
        }

        public void setInputChannelId(String inputChannelId) {
            this.inputChannelId = inputChannelId;
        }

        public ArrayList<String> getErrCode() {
            return errCode;
        }

        public void setErrCode(ArrayList<String> errCode) {
            this.errCode = errCode;
        }

        public ArrayList<String> getErrMesg() {
            return errMesg;
        }

        public void setErrMesg(ArrayList<String> errMesg) {
            this.errMesg = errMesg;
        }

        public void setRequestAccepted(boolean requestAccepted) {
            this.requestAccepted = requestAccepted;
        }

        @Override
        public boolean isRequestAccepted() {
            // TODO Auto-generated method stub
            return requestAccepted;
        }

        @Override
        public String getErrorCode() {
            if (errCode != null && errCode.size() > 0)
                return errCode.get(0);
            else
                return null;
        }

        @Override
        public String getErrorMessage() {
            if (errMesg != null && errMesg.size() > 0)
                return errMesg.get(0);
            else
                return null;

        }

        public String getWtn() {
            return wtn;
        }

        public void setWtn(String wtn) {
            this.wtn = wtn;
        }

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getProductType() {
            return productType;
        }

        public void setProductType(String productType) {
            this.productType = productType;
        }

        public String getProductId() {
            return productId;
        }

        public void setProductId(String productId) {
            this.productId = productId;
        }

        public String getBan() {
            return ban;
        }

        public void setBan(String ban) {
            this.ban = ban;
        }

        public String getRequestType() {
            return requestType;
        }

        public void setRequestType(String requestType) {
            this.requestType = requestType;
        }

        public String getBtnCustCode() {
            return btnCustCode;
        }

        public void setBtnCustCode(String btnCustCode) {
            this.btnCustCode = btnCustCode;
        }

        public String getCorrelationId() {
            return correlationId;
        }

        public void setCorrelationId(String corelationId) {
            this.correlationId = corelationId;
        }

        public boolean isHierarchyCalloutFlag() {
            return hierarchyCalloutFlag;
        }

        public void setHierarchyCalloutFlag(boolean hierarchyCalloutFlag) {
            this.hierarchyCalloutFlag = hierarchyCalloutFlag;
        }

        public BigDecimal getMajorVersionNumber() {
            return majorVersionNumber;
        }

        public void setMajorVersionNumber(BigDecimal majorVersionNumber) {
            this.majorVersionNumber = majorVersionNumber;
        }

        public BigDecimal getMinorVersionNumber() {
            return minorVersionNumber;
        }

        public void setMinorVersionNumber(BigDecimal minorVersionNumber) {
            this.minorVersionNumber = minorVersionNumber;
        }

        public boolean isCallVCSR() {
            return callVCSR;
        }

        public void setCallVCSR(boolean callVCSR) {
            this.callVCSR = callVCSR;
        }

        public boolean isCallCBI() {
            return callCBI;
        }

        public void setCallCBI(boolean callCBI) {
            this.callCBI = callCBI;
        }

        public boolean isCallRCR() {
            return callRCR;
        }

        public void setCallRCR(boolean callRCR) {
            this.callRCR = callRCR;
        }

        public boolean isCallSR() {
            return callSR;
        }

        public void setCallSR(boolean callSR) {
            this.callSR = callSR;
        }

        public boolean isCallRTQ() {
            return callRTQ;
        }

        public void setCallRTQ(boolean callRTQ) {
            this.callRTQ = callRTQ;
        }

        public boolean isCallCPLUS() {
            return callCPLUS;
        }

        public void setCallCPLUS(boolean callCPLUS) {
            this.callCPLUS = callCPLUS;
        }

        public boolean isCallDupData() {
            return callDupData;
        }

        public void setCallDupData(boolean callDupData) {
            this.callDupData = callDupData;
        }

        public boolean isCallEPWF() {
            return callEPWF;
        }

        public void setCallEPWF(boolean callEPWF) {
            this.callEPWF = callEPWF;
        }

        public boolean isCallPPP() {
            return callPPP;
        }

        public void setCallPPP(boolean callPPP) {
            this.callPPP = callPPP;
        }

        public boolean isCallDVARCDS() {
            return callDVARCDS;
        }

        public void setCallDVARCDS(boolean callDVARCDS) {
            this.callDVARCDS = callDVARCDS;
        }

        public boolean isCallEnsemble() {
            return callEnsemble;
        }

        public void setCallEnsemble(boolean callEnsemble) {
            this.callEnsemble = callEnsemble;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public String getCompositeViewRequestType() {
            return compositeViewRequestType;
        }

        public void setCompositeViewRequestType(String compositeViewRequestType) {
            this.compositeViewRequestType = compositeViewRequestType;
        }

        public String getAccountNumber() {
            return accountNumber;
        }

        public void setAccountNumber(String accountNumber) {
            this.accountNumber = accountNumber;
        }

        public String getServiceOrderNumber() {
            return serviceOrderNumber;
        }

        public void setServiceOrderNumber(String serviceOrderNumber) {
            this.serviceOrderNumber = serviceOrderNumber;
        }

        public String getRCRInvariantId() {
            return RCRInvariantId;
        }

        public void setRCRInvariantId(String rCRInvariantId) {
            RCRInvariantId = rCRInvariantId;
        }

        public String getServiceType() {
            return serviceType;
        }

        public void setServiceType(String serviceType) {
            this.serviceType = serviceType;
        }

        public String getUserId() {
            return userId;
        }

        public void setUserId(String userId) {
            this.userId = userId;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getMsgSourceSystem() {
            return msgSourceSystem;
        }

        public void setMsgSourceSystem(String msgSourceSystem) {
            this.msgSourceSystem = msgSourceSystem;
        }

        public boolean isAcctRequired() {
            return acctRequired;
        }

        public void setAcctRequired(boolean acctRequired) {
            this.acctRequired = acctRequired;
        }

        public boolean isPrdtRequired() {
            return prdtRequired;
        }

        public void setPrdtRequired(boolean prdtRequired) {
            this.prdtRequired = prdtRequired;
        }

        /**
         * @return the pendingChangesInd
         */
        public boolean isPendingChangesInd() {
            return pendingChangesInd;
        }

        /**
         * @param pendingChangesInd
         *            the pendingChangesInd to set
         */
        public void setPendingChangesInd(boolean pendingChangesInd) {
            this.pendingChangesInd = pendingChangesInd;
        }

        /**
         * @return the assocProdInd
         */
        public String getAssocProdInd() {
            return assocProdInd;
        }

        /**
         * @param assocProdInd
         *            the assocProdInd to set
         */
        public void setAssocProdInd(String assocProdInd) {
            this.assocProdInd = assocProdInd;
        }

        /**
         * @return the svcAddrLimiter
         */
        public String getSvcAddrLimiter() {
            return svcAddrLimiter;
        }

        /**
         * @param svcAddrLimiter
         *            the svcAddrLimiter to set
         */
        public void setSvcAddrLimiter(String svcAddrLimiter) {
            this.svcAddrLimiter = svcAddrLimiter;
        }

        /**
         * @return the productLimiter
         */
        public String getProductLimiter() {
            return productLimiter;
        }

        /**
         * @param productLimiter
         *            the productLimiter to set
         */
        public void setProductLimiter(String productLimiter) {
            this.productLimiter = productLimiter;
        }

        /**
         * @return the lineLimiter
         */
        public int getLineLimiter() {
            return lineLimiter;
        }

        /**
         * @param lineLimiter
         *            the lineLimiter to set
         */
        public void setLineLimiter(int lineLimiter) {
            this.lineLimiter = lineLimiter;
        }

        /**
         * @return the authorizedData
         */
        public List<String> getAuthorizedData() {
            return authorizedData;
        }

        /**
         * @param authorizedData
         *            the authorizedData to set
         */
        public void setAuthorizedData(List<String> authorizedData) {
            this.authorizedData = authorizedData;
        }

        /**
         * @return the cspReqType
         */
        public String getCspReqType() {
            return cspReqType;
        }

        /**
         * @param cspReqType
         *            the cspReqType to set
         */
        public void setCspReqType(String cspReqType) {
            this.cspReqType = cspReqType;
        }

        /**
         * @return the dupDataCallNotRequired
         */
        public boolean isDupDataCallNotRequired() {
            return dupDataCallNotRequired;
        }

        /**
         * @param dupDataCallNotRequired
         *            the dupDataCallNotRequired to set
         */
        public void setDupDataCallNotRequired(boolean dupDataCallNotRequired) {
            this.dupDataCallNotRequired = dupDataCallNotRequired;
        }

        public String getStateOrProvince() {
            return stateOrProvince;
        }

        public void setStateOrProvince(String stateOrProvince) {
            this.stateOrProvince = stateOrProvince;
        }

        public String getZipCode() {
            return zipCode;
        }

        public void setZipCode(String zipCode) {
            this.zipCode = zipCode;
        }

        public String getBaid() {
            return baid;
        }

        public void setBaid(String baid) {
            this.baid = baid;
        }



        public boolean isMyaBillingAndPaymentSection() {
            return myaBillingAndPaymentSection;
        }

        public void setMyaBillingAndPaymentSection(
                boolean myaBillingAndPaymentSection) {
            this.myaBillingAndPaymentSection = myaBillingAndPaymentSection;
        }

        public boolean isSingleProductIdInfo() {
            return singleProductIdInfo;
        }

        public void setSingleProductIdInfo(boolean singleProductIdInfo) {
            this.singleProductIdInfo = singleProductIdInfo;
        }

        public String getSourceSystem() {
            return sourceSystem;
        }

        public void setSourceSystem(String sourceSystem) {
            this.sourceSystem = sourceSystem;
        }

        public boolean isCallQCCTLID() {
            return callQCCTLID;
        }

        public void setCallQCCTLID(boolean callQCCTLID) {
            this.callQCCTLID = callQCCTLID;
        }

        public boolean isOCNAllowed() {
            return isOCNAllowed;
        }

        public void setOCNAllowed(boolean isOCNAllowed) {
            this.isOCNAllowed = isOCNAllowed;
        }

        public boolean isOrderTypeAllowed() {
            return isOrderTypeAllowed;
        }

        public void setOrderTypeAllowed(boolean isOrderTypeAllowed) {
            this.isOrderTypeAllowed = isOrderTypeAllowed;
        }
    }

byte[]方法中,我尝试对数据进行反序列化,但是当数据被破坏时,它会抛出异常。我有一个断点,让我停止代码并检查MD5。

0 个答案:

没有答案