当前位置:网站首页>WCF TCP protocol transmission
WCF TCP protocol transmission
2022-06-24 08:16:00 【Changchun procedural ape】
1、 Server side :
using com.jbossjf.common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
// Author Wei :jbossjf
namespace com.jbossjf.core
{
public class WcfService
{
private static ServiceHost basefileHost = null;
public int StartWcfService()
{
try
{
if (basefileHost == null)
{
// Use code binding
Uri tcpa = new Uri("net.tcp://" + CommonHelp.ip + ":8866/BasefileService");
basefileHost = new ServiceHost(typeof(com.jbossjf.core.BasefileService), tcpa);
ServiceMetadataBehavior mBehave = new ServiceMetadataBehavior();
NetTcpBinding tcpb = new NetTcpBinding()
{
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxStringContentLength = 2147483647
},
Security = new NetTcpSecurity()
{
Mode = SecurityMode.None
},
ReceiveTimeout = new TimeSpan(0,1,30)
,
SendTimeout = new TimeSpan(0,1,30)
,
MaxBufferSize = 65536
,
MaxBufferPoolSize = 524288
,
MaxReceivedMessageSize = 65536
//OpenTimeout = new TimeSpan(0,0,5)
//,
//CloseTimeout = new TimeSpan(0,1,0)
};
basefileHost.Description.Behaviors.Add(mBehave);
basefileHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
basefileHost.AddServiceEndpoint(typeof(com.jbossjf.core.IBasefileService), tcpb, tcpa);
// NetTcpBinding binding = new NetTcpBinding()
basefileHost.Open();
return 1;
}
}
catch(Exception ex){
CommonHelp.WriteLog(ex.Message);
}
return 0;
}
public int CloseWcfService()
{
try
{
if (basefileHost != null)
{
basefileHost.Close();
return 1;
}
}
catch { }
return 0;
}
// using (ServiceReferenceDemo.Service1Client sc = new ServiceReferenceDemo.Service1Client())
//{
// sc.Open();
// MessageBox.Show(sc.GetData(10));
// sc.Close();
//}
}
}
2、 client

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace com.jbossjf.core.WCF
{
public class WcfHelp
{
public static com.jbossjf.core.BasefileServiceReference.BasefileServiceClient _BasefileServiceReference = null;
public com.jbossjf.core.BasefileServiceReference.BasefileServiceClient GetBasefileServiceClient()
{
try
{
if (_BasefileServiceReference == null)
{
_BasefileServiceReference = new core.BasefileServiceReference.BasefileServiceClient();
// if (!_BasefileServiceReference.State.ToString().Equals("Created"))
_BasefileServiceReference.Open();
}
if (_BasefileServiceReference.State.ToString().Equals("Faulted"))
{
try
{
_BasefileServiceReference = null;
_BasefileServiceReference = new core.BasefileServiceReference.BasefileServiceClient();
_BasefileServiceReference.Open();
}
catch { }
//_BasefileServiceReference = new core.BasefileServiceReference.BasefileServiceClient();
}
}
catch { }
return _BasefileServiceReference;
}
}
}
DataTable dt = _WcfHelp.GetBasefileServiceClient().FindFermentationALL("jbossjf");
边栏推荐
- Swift 基础 闭包/Block的使用(源码)
- 快速读论文----AD-GCL:Adversarial Graph Augmentation to Improve Graph Contrastive Learning
- 1279_ Vsock installation failure resolution when VMware player installs VMware Tools
- Pagoda panel installation php7.2 installation phalcon3.3.2
- Optimization and practice of Tencent cloud EMR for cloud native containerization based on yarn
- 51单片机_外部中断 与 定时/计数器中断
- 工控机防破解
- Vulnhub靶机:BOREDHACKERBLOG_ CLOUD AV
- All you know is the test pyramid?
- Model effect optimization, try a variety of cross validation methods (system operation)
猜你喜欢

LabVIEW查找n个元素数组中的质数

Vulnhub靶机:BOREDHACKERBLOG: SOCIAL NETWORK

软件工程导论——第二章——可行性研究

1-4metaploitable2 introduction

一文带你了解Windows操作系统安全,保护自己的电脑不受侵害

首次曝光 唯一全域最高等级背后的阿里云云原生安全全景图

Svn actual measurement common operation record operation

Use of swift basic closure /block (source code)

Examples of corpus data processing cases (reading multiple text files, reading multiple files specified under a folder, decoding errors, reading multiple subfolder text, batch renaming of multiple fil

Swift Extension NetworkUtil(網絡監聽)(源碼)
随机推荐
Shader common functions
Swift 基础 闭包/Block的使用(源码)
UTC、GMT、CST
FPGA的虚拟时钟如何使用?
Future trends in automated testing
Auto usage example
Transformers pretrainedtokenizer class
2021-03-09 COMP9021第七节课笔记
os.path.join()使用过程中遇到的坑
Leetcode 207: course schedule (topological sorting determines whether the loop is formed)
模型效果优化,试一下多种交叉验证的方法(系统实操)
3-list introduction
Signature analysis of app x-zse-96 in a Q & a community
Decltype usage introduction
2022 PMP project management examination agile knowledge points (1)
Upgrade Mysql to the latest version (mysql8.0.25)
不止于观测|阿里云可观测套件正式发布
Model effect optimization, try a variety of cross validation methods (system operation)
Interview tutorial - multi thread knowledge sorting
Selenium IDE的安装以及使用