Click here to Skip to main content
15,913,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Finding a structures address Pin
Prakash Nadar31-Mar-04 14:44
Prakash Nadar31-Mar-04 14:44 
GeneralRe: Finding a structures address Pin
gUrM33T31-Mar-04 16:47
gUrM33T31-Mar-04 16:47 
GeneralRe: Finding a structures address Pin
John R. Shaw31-Mar-04 21:56
John R. Shaw31-Mar-04 21:56 
Questionhow to draw the background bmp for the statusbar? Pin
benben31-Mar-04 3:52
benben31-Mar-04 3:52 
AnswerRe: how to draw the background bmp for the statusbar? Pin
Alexander M.,1-Apr-04 3:44
Alexander M.,1-Apr-04 3:44 
GeneralThank you very much! Pin
benben1-Apr-04 17:23
benben1-Apr-04 17:23 
GeneralWindows Service vs. Sockets Pin
RickyC31-Mar-04 3:42
RickyC31-Mar-04 3:42 
GeneralMessage Pump Missing? Pin
Xiangyang Liu 刘向阳31-Mar-04 4:41
Xiangyang Liu 刘向阳31-Mar-04 4:41 
Here is a possible cause of your problem:

The OnAccept() method is not called because there is no message pump in your windows service.

Here is my understanding (see MFC source code): When a request comes from a remote program, it is turned into a windows WM_SOCKET_NOTIFY message and posted to an internal window used by CAsynSocket. When the WM_SOCKET_NOTIFY message is processed by MFC, it will invoke the event handlers such as OnAccept, OnReceive, etc. Unless you added a message loop to your windows service, the WM_SOCKET_NOTIFY message will never be processed.

If you cut and paste your code into a MFC dialog based application, assuming there is no other bug, it will work.

If that is confirmed to be the problem, there are at least two relatively easy solutions.

1. Start a separate thread from the windows service. Create the socket in this new thread, call Create/Bind/Listen for the socket, then use a loop to call Accept/Reciev/Send (i.e. don't rely on the OnAccept notification).

2. Move everything to a dialog based application, when the program works, use this special windows service[^] to run your application.

Good luck.

P.S. Solution 1 does not work if multiple clients have to connect to your server simultaneously, in which case you need to add a message pump and rely on the socket events.





My articles and software tools





GeneralRe: Message Pump Missing? Pin
RickyC31-Mar-04 5:59
RickyC31-Mar-04 5:59 
GeneralRe: Windows Service vs. Sockets Pin
Robert M Greene31-Mar-04 16:00
Robert M Greene31-Mar-04 16:00 
GeneralRe: What is "Visual Studio (MSI)"? Pin
Vasiliy Baranov31-Mar-04 3:36
Vasiliy Baranov31-Mar-04 3:36 
GeneralWin 32 error Pin
jetournier31-Mar-04 2:55
jetournier31-Mar-04 2:55 
GeneralRe: Win 32 error Pin
Antti Keskinen31-Mar-04 3:26
Antti Keskinen31-Mar-04 3:26 
GeneralRe: Win 32 error Pin
jetournier1-Apr-04 19:35
jetournier1-Apr-04 19:35 
GeneralSetCursor Pin
ns31-Mar-04 2:46
ns31-Mar-04 2:46 
GeneralRe: SetCursor Pin
Antti Keskinen31-Mar-04 3:23
Antti Keskinen31-Mar-04 3:23 
GeneralRe: SetCursor Pin
ns31-Mar-04 3:40
ns31-Mar-04 3:40 
GeneralRe: SetCursor Pin
ns31-Mar-04 4:05
ns31-Mar-04 4:05 
GeneralRe: SetCursor Pin
Antti Keskinen31-Mar-04 4:49
Antti Keskinen31-Mar-04 4:49 
GeneralRe: SetCursor Pin
ns31-Mar-04 8:51
ns31-Mar-04 8:51 
GeneralProblems with GetMsgProc & WH_GETMESSAGE using SetWindowsHookEx Pin
triptiarora31-Mar-04 1:57
triptiarora31-Mar-04 1:57 
GeneralMenu Bar Color Pin
olis31-Mar-04 0:57
olis31-Mar-04 0:57 
GeneralRe: Menu Bar Color Pin
ohadp31-Mar-04 2:13
ohadp31-Mar-04 2:13 
GeneralFile Property Pin
hb.sapto nugroho31-Mar-04 0:21
hb.sapto nugroho31-Mar-04 0:21 
GeneralRe: File Property Pin
David Crow31-Mar-04 2:07
David Crow31-Mar-04 2:07 

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.