2015-08-24 26 views

回答

1

你的意思是TCP嵌入式運輸/嵌入使用http?或只是TCP,但使用互聯網?

最後一個是肯定支持的。


要設置TCP connectionover WCF很簡單,只需使用NetTcpBinding的,你可以在C#代碼中設置這個或config文件這樣更好:

<system.serviceModel> 
    <bindings> 
    <netTcpBinding name="portSharingBinding" 
        portSharingEnabled="true" /> 
    </bindings> 
    <services> 
    <service name="MyService"> 
     <endpoint address="net.tcp://localhost/MyService" 
        binding="netTcpBinding" 
        contract="IMyService" 
        bindingConfiguration="portSharingBinding" /> 
    </service> 
    </services> 
</system.serviceModel> 

有建立一個TCP之間沒有型差分在專用網絡或公共一個(互聯網)

通道我強烈建議你閱讀A truely simple example to get started with TCP and WCF

+0

使用互聯網的TCP –

+0

答案與您的澄清改善。 @ murtaza – JuanK

+0

如果我創建一個wcf服務並在其中定義方法,那麼tcp客戶端將如何知道要調用哪個方法,因爲它只會發送TCP請求。 –

0

根據數據類型您可以使用(按照抽象的升序):

使用示例在文檔中給出。

TCP監聽https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener(v=vs.110).aspx

HttpListnerhttps://msdn.microsoft.com/en-us/library/system.net.httplistener(v=vs.110).aspx 一個很好的例子在這裏:https://www.codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server.aspx

或者使用一個完整的框架,像的WebAPI南希

http://www.asp.net/web-api

http://nancyfx.org/

不知道你是怎麼想送就很難推薦數據,但不重新發明輪子,如果你不就得了。