c#中的TCP连接超时....................................... [英] TCP Connection Timeout in c#....................................

查看:98
本文介绍了c#中的TCP连接超时.......................................的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的情况是有时客户端不可用,并且我正在使用TcpClient连接到它们.连接-如果它们不可用,则会抛出SocketException并且一切都很好.

我遇到的问题是我无法设置connect命令的超时-对于使用它的情况,它花费的时间太长.如何设置它?

I have a situation where clients are sometimes not available and I am connecting to them with TcpClient. Connect - if they aren''t available, a SocketException is thrown and all is well.

The problem I''m running into is that I can''t set the timeout of the connect command - it takes far too long for the situation I''m using it in. How do I set this?

推荐答案

http://social.msdn.microsoft.com/Forums/zh-CN/csharpgeneral/thread/2281199d-cd28-4b5c-95dc-5a888a6da30d/ [

你好,我相信昨天才有这个问题.这是一个常见的问题,您实际上无法设置timout.请查看以下问题并使用答案2:
等待一些特定的时间(如果有的话)响应不会取消事件 [
Hi there, we had this question only yesterday I believe. It is a common problem that you can''t actually set the timout. Please see the following question and use answer 2:
Wait for some specfic time if any response doesn''t come cancel an event[^]


这篇关于c#中的TCP连接超时.......................................的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆