Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one problem , that is 10014 erorr!!
i try check memory and socket values , what are you think about this?
what i have to do ? please help me ....!

What I have tried:

C++
#include "cUDPReceiver.h"


cUDPReceiver::cUDPReceiver(void)
{
}


cUDPReceiver::~cUDPReceiver(void)
{
}
void cUDPReceiver::Initializing(SOCKET		_socket )
{
	m_socket = _socket;
	ZeroMemory(&m_overlapped,sizeof(m_overlapped));

	m_nFlags = 0;	
	m_wsaBuf.len		= BUF_SIZE;
	m_wsaBuf.buf		= m_buf;

	OnRecv();
}
void cUDPReceiver::OnRecv()
{
	DWORD   dwBytes = 0, dwFlags = 0;
	int returnValue = 0;

	ZeroMemory(&m_overlapped,sizeof(m_overlapped));
	ZeroMemory(&m_lastSenderAddr,sizeof(m_lastSenderAddr));
	m_addrSize = sizeof(m_lastSenderAddr);

	m_wsaBuf.buf		= m_queueBuffer.GetBufferPoint();
	m_wsaBuf.len		= m_queueBuffer.GetRecvBytes();	

	__LOCK;
	returnValue = WSARecvFrom(m_socket,
		&m_wsaBuf,
		1,
		&dwBytes,
		&dwFlags,
		(SOCKADDR *)&m_lastSenderAddr,
		&m_addrSize, 
		&m_overlapped,
		NULL);

	__UNLOCK;

	if ( returnValue ==  SOCKET_ERROR )
	{
		if( WSAGetLastError() != WSA_IO_PENDING )
		{		
			//WSACleanup();
			OnRecv();
		}
	}
}
void cUDPReceiver::OnSend(SOCKADDR_IN		_addr, char* pData,const int _nSize)
{
	DWORD   dwBytes = 0;
	int returnValue = 0;

	__LOCK;

	m_wsaBuf.buf = pData;
	m_wsaBuf.len = _nSize;    

	returnValue = WSASendTo(m_socket, &m_wsaBuf, 1,
		&dwBytes, 0, (SOCKADDR *) & _addr,
		sizeof(_addr), &m_overlapped, NULL);

	__UNLOCK;

	if( returnValue == SOCKET_ERROR)
	{
		if(WSAGetLastError() != WSA_IO_PENDING)
		{
			printf("Error - fail wsasend \n");
		}
	}
}
void cUDPReceiver::SetLength(DWORD _dwSize)
{
	m_wsaBuf.len = _dwSize;
	m_queueBuffer.PushData(_dwSize);
}
char*		cUDPReceiver::GetBuffer()
{
	return m_queueBuffer.PopData();
}
SOCKADDR_IN cUDPReceiver::GetLastAddr()
{
	return m_lastSenderAddr;
}

void cUDPReceiver::Dispatch(char* pData)
{
}
Posted
Updated 6-Oct-17 23:10pm
v3

1 solution

If you don't understand an error message, Google it: 10014 socket error - Google Search[^]
The top link explains what the error means: Windows Sockets Error Codes (Windows)[^]
Quote:
WSAEFAULT
10014
Bad address.
The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr).


So now you know what the error message means, start using the debugger to look at you code while it runs, to find out which pointer is giving the problem, and what it is pointing at.
We cannot do that for you: we do not have any access to your system while your code is running!
 
Share this answer
 
Comments
Member 13450992 7-Oct-17 5:33am    
thanks for comment on my question and your advise!
but, i don't know this error, No matter how much read the msdn
So , i checked the memory address but there is no address anywhere...
OriginalGriff 7-Oct-17 5:54am    
The error message is pretty clear: check your pointers in the debugger and find out what you are pointing at.
I can't do that for you - this needs to be looked at while your code is running, and that is only possible on your system with the debugger.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900