15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CAsyncSocket and Close()

John and Cecilia -- jandce@iglobal.net
Thursday, November 07, 1996

Environment: VC++ 4.0/WIN95

I have derive a class from CAsyncSocket to catch the OnConnect(and others)
messages. Everything is working excellently except for one thing. When I
close the connection and attempt to connect to another site, I receive a
WSAECONNREFUSED error message in my OnConnect() handler. If I terminate my
program and start the program again, the connection phase works fine the
first time. Subsequent connection attempts fail until I restart the
program.

I have tried the following:

Constructor:
     FtpControl = new FtpSocket;
     FtpControl->Create();

Close Connection
    FtpControl->Close();
    delete FtpControl;
    FtpControl = new FtpSocket;    
    FtpControl->Create();

I have tried this with and with out the delete and new between the close
and create calls. I understand that the destructor for CAsyncSocket
automatically calls close. So I took out the call to close and get the same
results.

If I set up a call to close in my state engine, and wait for an OnClose
message after calling Close(), I never receive an OnCLose() message, even
though FD_CLOSE is a default for the Create() function.

Any help would be greatly appreciated. Thanks.

John Boehme
http://www.iglobal.net/pub/JohnAndCe/webmap.htm



Doug Boone -- dboone@fasttax.com
Monday, November 11, 1996

It could be a timing issue, network connections take a while to start and a
while to break.
  
Or it could be garbage left over from the last socket that isn't
re-initialized so you should look at setting FtpControl to NULL after the
delete and before the new so you'll get better stack trash.
 

----------
> From: John and Cecilia 
> To: MFC News Group 
> Subject: CAsyncSocket and Close()
> Date: Thursday, November 07, 1996 7:56 AM
> 
> Environment: VC++ 4.0/WIN95
> 
> I have derive a class from CAsyncSocket to catch the OnConnect(and
others)
> messages. Everything is working excellently except for one thing. When I
> close the connection and attempt to connect to another site, I receive a
> WSAECONNREFUSED error message in my OnConnect() handler. If I terminate
my
> program and start the program again, the connection phase works fine the
> first time. Subsequent connection attempts fail until I restart the
> program.
> 
> I have tried the following:
> 
> Constructor:
>      FtpControl = new FtpSocket;
>      FtpControl->Create();
> 
> Close Connection
>     FtpControl->Close();
>     delete FtpControl;
>     FtpControl = new FtpSocket;    
>     FtpControl->Create();
> 
> I have tried this with and with out the delete and new between the close
> and create calls. I understand that the destructor for CAsyncSocket
> automatically calls close. So I took out the call to close and get the
same
> results.
> 
> If I set up a call to close in my state engine, and wait for an OnClose
> message after calling Close(), I never receive an OnCLose() message, even
> though FD_CLOSE is a default for the Create() function.
> 
> Any help would be greatly appreciated. Thanks.
> 
> John Boehme
> http://www.iglobal.net/pub/JohnAndCe/webmap.htm




| Вернуться в корень Архива |