asyncsocket

Sporadic TCP connection failures (WSAEHOSTUNREACH)

余生颓废 提交于 2019-12-10 18:09:39
问题 On a local gigabit network, I have an application using a single TCP server and many clients. Each client pings the server every 30 seconds, by opening a TCP connection, sending it a status message, and closing. The server is set up using SocketAsyncEventArgs very similarly to the example shown HERE (omitted for brevity) The clients initiate the connection using a TcpClient. Relevant section of client code: using (TcpClient client = new TcpClient()) { IAsyncResult ar = client.BeginConnect

Socket.Shutdown throws SocketException

被刻印的时光 ゝ 提交于 2019-12-10 13:58:03
问题 I'm trying to implement async sockets for my project. Here's the code public void Start(int listeningPort) { var ipHostInfo = Dns.Resolve(Dns.GetHostName()); var ipAddress = ipHostInfo.AddressList[0]; var localEndPoint = new IPEndPoint(ipAddress, listeningPort); _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _listener.Bind(localEndPoint); _listener.Listen(3000); Started = true; Task.Factory.StartNew(() => { while (Started) { allDone.Reset(); _listener

Python - Asyncore (client) socket - Can not determaine connection status

时光毁灭记忆、已成空白 提交于 2019-12-10 11:54:59
问题 For some reason, self.connected of the asyncore.dispatcher class doesn't consider my socket to be connected on the client side. The server side sees the socket as connected and treats it as such, but the client doesn't know if it's connected or not and handle_connect doesn't "proc", so i can't use a overridden version of it to check if the socket is connected either. Any thoughts on this code why it ain't working: #!/usr/bin/python # -*- coding: iso-8859-15 -*- import asyncore from threading

.NET TcpClient/NetworkStream implementation that supports async operations and respects timeouts

孤者浪人 提交于 2019-12-10 05:16:25
问题 Based on the number of questions, forum posts, etc, it appears that the TcpClient/NetworkStream implementation in the BCL lacks decent support for cancelling IO operations. With the addition of Async methods in .NET 4.5, this lack of cancellation (or decent timeout support) makes things even more frustrating since it becomes even more complicated (nigh on impossible) to cancel a task that refuses to monitor its CancellationToken while performing IO. I have seen many implementations that spin

Visual Studio 2010 doesn’t stop at an unhandled exception inside a Socket.BeginReceive() callback - why?

眉间皱痕 提交于 2019-12-10 01:59:19
问题 Normally, when the debugger is attached, Visual Studio 2010 stops at an unhandled exception even if the Exceptions dialog doesn’t have the tickmark for the exception type in the “Thrown” column. The keyword here is unhandled; said dialog refers only to handled exceptions. However, in the following minimal example, Visual Studio 2010 does not stop at the exception for me, even though it appears in the Immediate Window as a first-chance exception: EDIT: The first minimal example I posted was

Telnet Blocking C# TCP Server

允我心安 提交于 2019-12-08 10:00:44
问题 I am writing a TCP server in C#, and have run into a strange and potentially a security issue as well. My basic arch for accepting new connections is as follows: A C# Socket listening on a port, using the AcceptAsync method to accept incoming connections. Spinning off accepted connections using the ThreadPool for finishing the accept. Everything works quite well, however everything grinds to a halt if someone telnets into the port. Symptoms: If I telnet into my server and do not send any data

How do I “flush” a TCP Client Buffer?

三世轮回 提交于 2019-12-08 06:02:13
问题 I've pulled from several examples to setup a Full Duplex C# TCP Client connected to a server. The basic concept is that the client and server both send/receive messages (commands and events). Therefore, I've developed a FullDuplexSocket class that exposes a Send method to send messages to the server and a event handler to receive messages from the server. Everything works except I can't seem to flush the buffer of messages received from the server. Each time the server sends a new message,

Set timeout for boost socket.connect

梦想的初衷 提交于 2019-12-08 01:52:38
问题 I am using boost::asio::connect on a tcp::socket . When all goes fine, the connect returns immediately but on a poor network, the connect times out after a log wait of 15 seconds. I cannot afford to wait that long and so want to reduce the timeout. Unfortunately I have not come across any solution so far. I see solutions where async_wait is been used together with deadline_timer but all those examples are for receive / send operations and not for connect. Can anyone help me with a sample code

Windows Phone 7 receive UDP packet (broadcast or unicast) over wifi

狂风中的少年 提交于 2019-12-07 12:16:28
问题 I have watched for several days the various forums regarding Windows Phone 7 however none gave me a definitive answer. So far I have not been able to receive a UDP packet (neither broadcast nor unicast) sent from a computer connected over wifi to a Windows Phone 7 device (running on emulator). Apparently UDP unicast should be supported and the code below runs correctly, however no UDP packet is received form the phone. I hope someone can correct the below code. Notice the below code follows

SocketAsyncEventArgs.Completed doesn't fire in Windows 8

可紊 提交于 2019-12-07 09:05:20
问题 When I compile this code on a machine with Windows 7 Ultimate and .NET 4 installed, it works just fine but when I try it on one with Windows 8 RTM and .NET 4.5 installed, Complete event never fires. class Program { private static Socket _Socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); private static void Main(string[] args) { _Socket.Bind(new IPEndPoint(IPAddress.Any, 5012)); _Socket.Listen(100); var arguments = new SocketAsyncEventArgs(); arguments