Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:31
Derek Waters21-Feb-02 11:31 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Nish Nishant21-Feb-02 11:41
sitebuilderNish Nishant21-Feb-02 11:41 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:43
Derek Waters21-Feb-02 11:43 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Nish Nishant21-Feb-02 11:53
sitebuilderNish Nishant21-Feb-02 11:53 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:32
Derek Waters21-Feb-02 11:32 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Paul M Watt21-Feb-02 19:08
mentorPaul M Watt21-Feb-02 19:08 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Mazdak21-Feb-02 19:48
Mazdak21-Feb-02 19:48 
GeneralA question about closesocket() Pin
lucy21-Feb-02 10:27
lucy21-Feb-02 10:27 
Hi codegurus there.

I am doing some network programming using MFC these days. I have two application, one is server, one is client. For server, I make it an un-blocking one using WSAAsyncSelect, and specify to respond to the following network event:
FD_READ | FD_WRITE | FD_ACCEPT | FD_CLOSE

At the client end, it's simple. I have three menu item, one is open_connection, one is close_connection, the other is send_receive. Here's part of my code for client:
OnConnectionClose()
{ shutdown(mysocket, SD_SEND);
  closesocket(mysocket);
}
OnConnectionOpen()
{ mysocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  connect(mysocket, (LPSOCKADDR)&saServer, sizeof(saServer));
}
OnSendReceive()
{ send(mysocket, szBuf, strlen(szBuf),0);
  recv(mysocket, szBuf, sizeof(szBuf), 0);
}

And at server end, I respond to the network event like this:
OnNetWorkEvent(WPARAM wParam, LPARAM lParam)
{
   switch(WSASELECTEVENT(lParam)
   {
   case FD_CLOSE:
       closesocket(wParam);
       TRACE("FD_CLOSE received\n");
       break;
   case FD_ACCEPT: 
       ... ...
   }
}

the problem here is: on client end, if I do "open_connection", then "close_connection", the server end will receive the FD_CLOSE event. But if I do "open_connection", "send_receive", then "close_connection", the server end will not receive the FD_CLOSE event. All other events are handled correctly. Could anybody tell me what's wrong with my coding?Confused | :confused:

Thank you all very much in advance!Rose | [Rose]
GeneralRe: A question about closesocket() Pin
Joaquín M López Muñoz21-Feb-02 10:39
Joaquín M López Muñoz21-Feb-02 10:39 
GeneralRe: A question about closesocket() Pin
lucy21-Feb-02 10:52
lucy21-Feb-02 10:52 
GeneralRe: A question about closesocket() Pin
Joaquín M López Muñoz21-Feb-02 10:57
Joaquín M López Muñoz21-Feb-02 10:57 
GeneralRe: A question about closesocket() Pin
lucy21-Feb-02 11:14
lucy21-Feb-02 11:14 
GeneralVS .NET and WinXP(DX8.0) Pin
Hadi Rezaee21-Feb-02 10:19
Hadi Rezaee21-Feb-02 10:19 
GeneralRe: VS .NET and WinXP(DX8.0) Pin
Joaquín M López Muñoz21-Feb-02 10:40
Joaquín M López Muñoz21-Feb-02 10:40 
GeneralRe: VS .NET and WinXP(DX8.0) Pin
Hadi Rezaee21-Feb-02 22:27
Hadi Rezaee21-Feb-02 22:27 
QuestionHow can i set the initial folder selected in SHBrowseForFolder? Pin
Shog921-Feb-02 10:08
sitebuilderShog921-Feb-02 10:08 
AnswerRe: How can i set the initial folder selected in SHBrowseForFolder? Pin
Joaquín M López Muñoz21-Feb-02 10:14
Joaquín M López Muñoz21-Feb-02 10:14 
GeneralRe: How can i set the initial folder selected in SHBrowseForFolder? Pin
Shog921-Feb-02 11:05
sitebuilderShog921-Feb-02 11:05 
AnswerRe: How can i set the initial folder selected in SHBrowseForFolder? Pin
Michael Dunn21-Feb-02 10:48
sitebuilderMichael Dunn21-Feb-02 10:48 
AnswerRe: How can i set the initial folder selected in SHBrowseForFolder? Pin
PJ Arends21-Feb-02 15:42
professionalPJ Arends21-Feb-02 15:42 
GeneralRe: How can i set the initial folder selected in SHBrowseForFolder? Pin
Shog921-Feb-02 20:06
sitebuilderShog921-Feb-02 20:06 
Generalwinsock packets delimiter parsing Pin
Kuniva21-Feb-02 9:50
Kuniva21-Feb-02 9:50 
GeneralRe: winsock packets delimiter parsing Pin
Joaquín M López Muñoz21-Feb-02 10:03
Joaquín M López Muñoz21-Feb-02 10:03 
Generalcannot find or open a required DBG file VC.NET Pin
JoeSox21-Feb-02 8:24
JoeSox21-Feb-02 8:24 
GeneralRe: cannot find or open a required DBG file VC.NET Pin
Joaquín M López Muñoz21-Feb-02 9:04
Joaquín M López Muñoz21-Feb-02 9:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.