当前位置:网站首页>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");
边栏推荐
- 487. 最大连续1的个数 II ●●
- 2021-03-16 COMP9021第九节课笔记
- Swift extension networkutil (network monitoring) (source code)
- [run the script framework in Django and store the data in the database]
- MySQL source and target table row count check
- 小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
- Vulnhub靶机:BOREDHACKERBLOG_ CLOUD AV
- [test development] first knowledge of software testing
- "Adobe international certification" about Adobe Photoshop, creating and modifying brush tutorials?
- SCM stm32f103rb, BLDC DC motor controller design, schematic diagram, source code and circuit scheme
猜你喜欢

Vulnhub target: boredhackerblog: social network

For a detailed explanation of flex:1, flex:1

Pipeline concept of graphic technology

GraphMAE----論文快速閱讀

Vulnhub target: boredhackerblog_ CLOUD AV

Écouter le réseau d'extension SWIFT (source)

有关iframe锚点,锚点出现上下偏移,锚点出现页面显示问题.iframe的srcdoc问题

Swift foundation features unique to swift
![3D数学基础[十七] 平方反比定理](/img/59/bef931d96883288766fc94e38e0ace.png)
3D数学基础[十七] 平方反比定理

Oracle advanced SQL qualified query
随机推荐
Future trends in automated testing
GraphMAE----论文快速阅读
487. 最大连续1的个数 II ●●
[introduction to point cloud dataset]
Installation and use of selenium IDE
一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
LINQ query (2)
Svn actual measurement common operation record operation
Swift 基础 闭包/Block的使用(源码)
有关iframe锚点,锚点出现上下偏移,锚点出现页面显示问题.iframe的srcdoc问题
论文笔记: 多标签学习 DM2L
The monthly salary of two years after graduation is 36K. It's not difficult to say
Methods of vector operation and coordinate transformation
Redolog and binlog
transformers PreTrainedTokenizer类
Saccadenet: use corner features to fine tune the two stage prediction frame | CVPR 2020
In the post epidemic era, the home service robot industry has just set sail
2021-03-04 COMP9021第六节课笔记
Vulnhub target: boredhackerblog: social network
Upgrade Mysql to the latest version (mysql8.0.25)