Click here to Skip to main content

C / C++ / MFC

    RSS: RSS Feed

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
AnswerRe: "Virtual" Command Prompt PinmemberHristo Bojilov12:39 13 Mar '10  
GeneralRe: "Virtual" Command Prompt [modified] Pinmemberhxhl9513:31 13 Mar '10  
GeneralRe: "Virtual" Command Prompt Pinmemberhxhl9514:41 13 Mar '10  
AnswerRe: "Virtual" Command Prompt PinmemberStephen Hewitt19:23 13 Mar '10  
QuestionModeless dialog closing when 'Enter' key is pressed? PinmemberSpawn@Melmac9:05 13 Mar '10  
AnswerRe: Modeless dialog closing when 'Enter' key is pressed? PinmemberSpawn@Melmac9:17 13 Mar '10  
QuestionSOCKET_ERROR when calling send method from seperate class PinmemberOmar El Fata7:49 13 Mar '10  
Hi,
 
I have two classes, MainDlg.cpp, and Game.cpp . My MainDlg.cpp file is responsible for TCP communication, and it works fine on its own. I initially start MainDlg.cpp and then I start the Game.cpp class from there. Iam trying to call the DoSend() (on MainDlg.cpp) method from the Game.cpp file and it just results in a SOCKET_ERROR !
 
Just for experimentaion I've tried to call a method on MainDlg.cpp from Game.cpp to display a simple MessageBox and it works, so the problem is not with the class object I created.
 
This is how I created/call the Game.cpp object on MainDlg.cpp
 
Game* game = new Game;
game->Create(Game::IDD);
 
When the Game.cpp dialog comes up, this is how I execute the method on MainDlg.cpp:
CMainDlg* Main = new CMainDlg;
Main->GetResults();
 

In MainDlg.cpp :
 
GetResults method: <-- Works fine when run locally
void CMainDlg::GetResults()
{
	Message_PDU Message;
	Message.iMessageNumber = 80;
	DoSend(Message);
}
 
DoSend Method: <-- Works fine when run locally
void CMainDlg::DoSend(Message_PDU Message) // Send Message to Server
{	
	int iBytesSent;
	iBytesSent = send(m_iSocket, (char *) &Message, sizeof(Message_PDU), 0);
	if(SOCKET_ERROR == iBytesSent)
	{
		MessageBox("Failed to send","Client");
	}
}
 

Any help will be really appreciated!
QuestionRe: SOCKET_ERROR when calling send method from seperate class PinmvpCPallini7:56 13 Mar '10  
AnswerRe: SOCKET_ERROR when calling send method from seperate class PinmemberOmar El Fata8:08 13 Mar '10  
GeneralRe: SOCKET_ERROR when calling send method from seperate class PinmemberOmar El Fata8:45 13 Mar '10  
AnswerRe: SOCKET_ERROR when calling send method from seperate class Pinmemberkrmed11:26 13 Mar '10  
GeneralRe: SOCKET_ERROR when calling send method from seperate class PinmemberOmar El Fata12:01 13 Mar '10  
QuestionWindow class, caption Pinmembertrioum5:26 13 Mar '10  
AnswerRe: Window class, caption PinmemberEugen Podsypalnikov5:34 13 Mar '10  
GeneralRe: Window class, caption Pinmembertrioum5:43 13 Mar '10  
GeneralRe: Window class, caption PinmemberEugen Podsypalnikov13:58 13 Mar '10  
QuestionRe: Window class, caption PinmvpDavidCrow6:20 13 Mar '10  
AnswerRe: Window class, caption Pinmember ThatsAlok 20:21 14 Mar '10  
QuestionHow can use VB dll in VC++ code? PinmemberLe@rner2:45 13 Mar '10  
AnswerRe: How can use VB dll in VC++ code? PinmemberLunaticFringe3:33 13 Mar '10  
AnswerRe: How can use VB dll in VC++ code? Pinmember ThatsAlok 20:24 14 Mar '10  
AnswerRe: How can use VB dll in VC++ code? Pinmembershivanandgupta21:30 14 Mar '10  
QuestionCalling vb dll functions in my vc code Pinmemberlearningvisualc22:23 12 Mar '10  
AnswerRe: Calling vb dll functions in my vc code Pinmembershivanandgupta1:36 13 Mar '10  
AnswerRe: Calling vb dll functions in my vc code Pinmembershivanandgupta1:51 13 Mar '10  

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.120210.1 | Last Updated 14 Feb 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid