asyncsocket

boost::asio async handlers invoked without error after cancellation

一个人想着一个人 提交于 2019-12-07 06:09:19
问题 My code uses boost::asio and io_service in a single thread to perform various socket operations. All operations are asynchronous and every handler depends on the boost::system::error_code (particularly boost::asio::error::operation_aborted ) to determine the result of the operation. It's been working perfectly well until I changed the logic to make several concurrent connections and pick the fastest one. That is, when the first async_read_some handler fires, I cancel other sockets (shutdown,

How do I “flush” a TCP Client Buffer?

强颜欢笑 提交于 2019-12-06 22:07:41
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, the buffer in my socket contains all the old messages (already read) and the new message(s). I could

Set timeout for boost socket.connect

爷,独闯天下 提交于 2019-12-06 05:21:24
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 for boost::asio::connect(socket, endpoints); . Requirement is that it should timeout in 5 seconds

How receive a complete screenshot in Async socket?

帅比萌擦擦* 提交于 2019-12-06 02:07:50
问题 I have a Java android code that sends data (image or text) to a C# application, to receive these data I'm using Async socket. But exists a problem that is relative to BeginReceive() function is not receiving the complete data when is sent an image.. Then how I can make a kind of "loop" to receive full data and after show the image on Picturebox (for example)? Form private Listener listener; private Thread startListen; private Bitmap _buffer; public frmMain() { InitializeComponent(); } private

python asyncio run event loop once?

感情迁移 提交于 2019-12-05 21:39:24
问题 I am trying to understand the asyncio library, specifically with using sockets. I have written some code in an attempt to gain understanding, I wanted to run a sender and a receiver sockets asynchrounously. I got to the point where I get all data sent up till the last one, but then I have to run one more loop. Looking at how to do this, I found this link from stackoverflow, which I implemented below -- but what is going on here? Is there a better/more sane way to do this than to call stop

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

时光毁灭记忆、已成空白 提交于 2019-12-05 20:49:57
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 all suggestions so far given on other forums, namely: Send a packet first to the intended destination

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

允我心安 提交于 2019-12-05 01:59:31
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 fixed by the first answer I received, but unfortunately the following example still exhibits the problem:

CocoaAsyncSocket's read and write delegates are not firing & code organization

笑着哭i 提交于 2019-12-05 00:58:08
问题 I'm trying to do the following with a modified version of the echo server example that comes with the cocoaasyncsocket library: 1) open a connection to a python script acting as a server 2) send data // works, but delegate doesn't fire 3) receive data back // delegate doesn't fire 4) disconnect // doesn't disconnect, apparently still in my thread Currently I open a connection in the didFinishLaunchingWithOptions delegate, and then attempt to send data in the didConnectToHost delegate. I then

How to receive Multicast UDP?

妖精的绣舞 提交于 2019-12-04 16:52:15
I'm using GCDAsyncUdpSocket and i can send either Multicast or normal UDP packets. I'm receiving normal packets with no problem but I cant receive Multicast packets from another iOS device. To receive I use: - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress: (NSData *)address withFilterContext:(id)filterContext { NSString *msg = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; NSString *host = nil; uint16_t port = 0; [GCDAsyncUdpSocket getHost:&host port:&port fromAddress:address]; if (msg) { NSLog(@"Message = %@, Adress = %@

is there any pool for ThreadingMixIn and ForkingMixIn for SocketServer?

陌路散爱 提交于 2019-12-04 06:01:18
I was trying to make an http proxy using BaseHttpServer which is based on SocketServer which got 2 asynchronous Mixins (ThreadingMixIn and ForkingMixIn) the problem with those two that they work on each request (allocate a new thread or fork a new subprocess for each request) is there a Mixin that utilize a pool of let's say 4 subprocesses and 40 threads in each so requests get handled by those already created threads ? because this would be a big performance gain and I guess it would save some resources. You could use a pool from concurrent.futures (in stdlib since Python 3.2): from