Click here to Skip to main content

C / C++ / MFC

   

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
GeneralRe: What's wrong.... Pinmemberbrahmma2:25 11 Jan '07  
GeneralRe: What's wrong.... PinmemberVuNic2:34 11 Jan '07  
GeneralRe: What's wrong.... PinmemberJohn R. Shaw14:54 11 Jan '07  
GeneralRe: What's wrong.... PinmemberVuNic19:36 11 Jan '07  
GeneralRe: What's wrong.... PinmemberWhiteSky20:57 11 Jan '07  
GeneralRe: What's wrong.... PinmemberAstricks0:04 12 Jan '07  
AnswerRe: What's wrong.... Pinmemberneilsolent2:12 11 Jan '07  
QuestionSocket Programming PinmemberSrikanthVinayak Ram1:48 11 Jan '07  
Hi Jobin,
 
I have created a simple example to simulate TCP using MFC CSocket. The purpose of the code is Server Listens at port number 6000. Once client gets connects to 6000, client sends a message to Server and the server should display the received message. The server code is running correctly in the Application generated by AppWizardExe (include windows sockets check box Yes)but not at console based program.
 
The code is as follows
 
s.Create (6000);
s.Listen ();
s.Accept (t);
n = t.Receive ((void*)l,20);
l[n] = 0;
cout<<l<<endl;
t.Close ();
s.Close ();
 
The above code is not giving any compilation errors.
 
In the above server code, the Listen is becoming blocking incase of AppWizard application code(which is correct) butin case of console based application it is non blocking. Since it is non blocking in case of console, Accept function is getting executed and I am getting Abort Retry Fail message. I debugged in console based application and found that the error is coming at the call of "AfxGetInstanceHandle". My investigation ended here. I did not understand why the difference. I tried another thing in the same code. Before calling all the functions, I called AfxSocketInit function. Because of this call, the socket create statement itself is getting failed. Please clarify where I am going wrong.
 
Thanks & Regards
Srikanth
 
Srikanth
AnswerRe: Socket Programming PinmemberMark Salsbery5:13 11 Jan '07  
AnswerRe: Socket Programming PinmemberDavid Leyva10:31 11 Jan '07  
QuestionRe: Socket Programming PinmemberSrikanthVinayak Ram18:40 11 Jan '07  
AnswerRe: Socket Programming PinmemberMark Salsbery6:37 12 Jan '07  
AnswerRe: Socket Programming PinmemberMark Salsbery6:39 12 Jan '07  
QuestionCDateTimeCtrl ideal size PinmemberWatz1:02 11 Jan '07  
QuestionSimplest way to display data in table form Pinmemberldsdbomber0:33 11 Jan '07  
AnswerRe: Simplest way to display data in table form PinmemberRage1:17 11 Jan '07  
GeneralRe: Simplest way to display data in table form Pinmemberldsdbomber1:38 11 Jan '07  
QuestionHow to add rich edit control ?? PinmemberSuresh H0:10 11 Jan '07  
AnswerRe: How to add rich edit control ?? Pinmemberprasad_som0:25 11 Jan '07  
GeneralRe: How to add rich edit control ?? PinmemberSuresh H0:45 11 Jan '07  
AnswerRe: How to add rich edit control ?? Pinmemberprasad_som1:08 11 Jan '07  
GeneralRe: How to add rich edit control ?? PinmemberSuresh H1:22 11 Jan '07  
AnswerRe: How to add rich edit control ?? Pinmemberprasad_som1:26 11 Jan '07  
GeneralRe: How to add rich edit control ?? PinmemberSuresh H1:43 11 Jan '07  
AnswerRe: How to add rich edit control ?? Pinmemberprasad_som1:55 11 Jan '07  

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

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


Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid