Prev: Request final critique
Next: Support for IPv6
From: huang on 14 Jun 2010 22:39 I have two MFC programs using CAsyncSocket to communicate. But I encounter a problem: when either one closed, another program still can use CAsyncSocket::Send to send once. And the return value is the length of the sending characters. After that when program call CAsyncSocket::Send again, it returns SOCKET_ERROR. How to dected disconnection immediately ?
From: Joseph M. Newcomer on 15 Jun 2010 10:04 Not sure what you mean here. What, for example, is "another program"? What is its relationship to any other part of your communications path? You can NEVER "detect disconnection immediately" because disconnection is going to depend on when the disconnection message arriives relative to other messages. There are potentially massive delays (seconds) between when a server disconnects and a client receives a disconnect message; meanwhile, the client is free to send other messages. You have to understand that there can NEVER be "immediate" notifications in a distributed network. You have given some vague handwave about what is happening. You use vague descriptions like "either one closed" and "another program" as if we have some idea what you are talking about. What you probably have is a server and a connected client. You must describe your observed behavior in terms of a server and a connected client, and say specifically what you are seeing in terms of a server and a connected client. And recognize that "disconnect" is a concept that involves sending a message (probably handled in FIFO order) from one to the other. And you have said NOTHING about the relationship of a close to a shutdown and whether or not shutdown is used, and if it is used, with what parameters. Given the vagueness of the description, I can only conjecture that the network stacks are working as they are defined to work, which is not what you are expecting. Expect them to work as defined. joe On Tue, 15 Jun 2010 10:39:59 +0800, "huang" <hzy633(a)gmail.com> wrote: >I have two MFC programs using CAsyncSocket to communicate. But I encounter a >problem: when either one closed, another program still can use >CAsyncSocket::Send to send once. And the return value is the length of the >sending characters. After that when program call CAsyncSocket::Send again, >it returns SOCKET_ERROR. > >How to dected disconnection immediately ? > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: Request final critique Next: Support for IPv6 |