Click here to Skip to main content
15,888,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Copying From Single Dimension Array To Multiple Dimension Array Pin
Stefan_Lang11-Mar-11 2:18
Stefan_Lang11-Mar-11 2:18 
QuestionRe: Copying From Single Dimension Array To Multiple Dimension Array Pin
David Crow11-Mar-11 2:49
David Crow11-Mar-11 2:49 
QuestionData Structure library Pin
pandit8410-Mar-11 2:32
pandit8410-Mar-11 2:32 
AnswerRe: Data Structure library Pin
Richard MacCutchan10-Mar-11 3:30
mveRichard MacCutchan10-Mar-11 3:30 
GeneralRe: Data Structure library Pin
pandit8410-Mar-11 23:39
pandit8410-Mar-11 23:39 
GeneralRe: Data Structure library Pin
Richard MacCutchan10-Mar-11 23:52
mveRichard MacCutchan10-Mar-11 23:52 
QuestionProblems with MFCTabCtrl/MDITabbedControl Pin
Dansveen10-Mar-11 2:27
Dansveen10-Mar-11 2:27 
QuestionHandle leaks in WinSock - WIndows Application (MFC) Pin
chevu10-Mar-11 1:09
chevu10-Mar-11 1:09 
Hi,

We are developing an application in which for comminication to outside module we are using WinSock based sime socket approach. Our requirement is to make sure connection will always be on, so for that reason when ever we are getting disconnected or not able to connect to outside module we keep trying after every 1 minute. Our problem starts here we have observered that on every retry of socket reconnect it is leaking exact 2 windows handles, we have tried so many options but none of them are working. Following is the code that we are using right now,

bool CSocketClass::ConnectToServer(int nLineNo)
{
	string strIPAddress;
	int nPortNo;
	SOCKET* l_ClientSocket;
	int ConnectionResult;

	//----------------------
	// Create a SOCKET for connecting to server
	if (nLineNo == 1)
	{
		m_objLine1.m_ClientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		strIPAddress = m_objLine1.m_strIPAddress;
		nPortNo = m_objLine1.m_nPortNo;
		l_ClientSocket = &(m_objLine1.m_ClientSocket);
	}
	else
	{
		m_objLine2.m_ClientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		strIPAddress = m_objLine2.m_strIPAddress;
		nPortNo = m_objLine2.m_nPortNo;
		l_ClientSocket = &(m_objLine2.m_ClientSocket);
	}
	if(INVALID_SOCKET == *l_ClientSocket)
	{
		closesocket(*l_ClientSocket);
		return false;
	}

	//----------------------
	// The sockaddr_in structure specifies the address family,
	// IP address, and port of the server to be connected to.
	sockaddr_in clientService; 
	clientService.sin_family = AF_INET;
	clientService.sin_addr.s_addr = inet_addr( strIPAddress.c_str() );
	clientService.sin_port = htons( nPortNo );

	//----------------------
	// Connect to server.
	ConnectionResult = connect( *l_ClientSocket, (SOCKADDR*) &clientService, sizeof(clientService) ) ;
	if (ConnectionResult == SOCKET_ERROR)
	{
		if (nLineNo == 1)
		{
			//ERROR in line1
		}
		else
		{
			//ERROR in line2
		}
		closesocket(*l_ClientSocket);
		return false;
	}
	else	//In case of successful connection 
	{	
		//Other actions
	}
	return true;
}


Can anyone help me? Thanks in advance.
AnswerRe: Handle leaks in WinSock - WIndows Application (MFC) Pin
Niklas L10-Mar-11 20:58
Niklas L10-Mar-11 20:58 
GeneralRe: Handle leaks in WinSock - WIndows Application (MFC) Pin
chevu10-Mar-11 21:33
chevu10-Mar-11 21:33 
AnswerRe: Handle leaks in WinSock - WIndows Application (MFC) Pin
bob1697211-Mar-11 1:54
bob1697211-Mar-11 1:54 
GeneralRe: Handle leaks in WinSock - WIndows Application (MFC) Pin
chevu11-Mar-11 2:34
chevu11-Mar-11 2:34 
GeneralRe: Handle leaks in WinSock - WIndows Application (MFC) Pin
bob1697211-Mar-11 3:10
bob1697211-Mar-11 3:10 
Questionhow to fastforward in directshow Pin
raj157610-Mar-11 1:01
raj157610-Mar-11 1:01 
AnswerRe: how to fastforward in directshow Pin
Richard MacCutchan10-Mar-11 3:28
mveRichard MacCutchan10-Mar-11 3:28 
AnswerRe: how to fastforward in directshow Pin
Cool_Dev10-Mar-11 5:19
Cool_Dev10-Mar-11 5:19 
QuestionProblem with RegisterPowerSettingNotification and USER32.dll. Pin
aangerma10-Mar-11 0:31
aangerma10-Mar-11 0:31 
AnswerRe: Problem with RegisterPowerSettingNotification and USER32.dll. Pin
Hans Dietrich10-Mar-11 0:35
mentorHans Dietrich10-Mar-11 0:35 
GeneralRe: Problem with RegisterPowerSettingNotification and USER32.dll. Pin
aangerma10-Mar-11 0:46
aangerma10-Mar-11 0:46 
GeneralRe: Problem with RegisterPowerSettingNotification and USER32.dll. Pin
Hans Dietrich10-Mar-11 0:50
mentorHans Dietrich10-Mar-11 0:50 
GeneralRe: Problem with RegisterPowerSettingNotification and USER32.dll. Pin
aangerma10-Mar-11 2:02
aangerma10-Mar-11 2:02 
QuestionShortcut files not filter from CFileDialog? Pin
Le@rner9-Mar-11 23:56
Le@rner9-Mar-11 23:56 
AnswerRe: Shortcut files not filter from CFileDialog? Pin
Hans Dietrich10-Mar-11 0:32
mentorHans Dietrich10-Mar-11 0:32 
GeneralRe: Shortcut files not filter from CFileDialog? Pin
Le@rner10-Mar-11 0:36
Le@rner10-Mar-11 0:36 
GeneralRe: Shortcut files not filter from CFileDialog? Pin
Hans Dietrich10-Mar-11 0:47
mentorHans Dietrich10-Mar-11 0:47 

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.