Click here to Skip to main content
15,923,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CFileDialog Pin
krmed25-Apr-08 0:42
krmed25-Apr-08 0:42 
GeneralRe: CFileDialog Pin
Saurabh.Garg25-Apr-08 2:25
Saurabh.Garg25-Apr-08 2:25 
GeneralRe: CFileDialog Pin
Saurabh.Garg25-Apr-08 2:22
Saurabh.Garg25-Apr-08 2:22 
GeneralRe: CFileDialog Pin
Saurabh.Garg24-Apr-08 22:27
Saurabh.Garg24-Apr-08 22:27 
GeneralRe: CFileDialog Pin
Nitheesh George24-Apr-08 22:59
Nitheesh George24-Apr-08 22:59 
QuestionRe: CFileDialog Pin
David Crow25-Apr-08 3:39
David Crow25-Apr-08 3:39 
GeneralRe: CFileDialog Pin
Michael Schubert25-Apr-08 4:40
Michael Schubert25-Apr-08 4:40 
GeneralNeed solution for WSAEWOULDBLOCK Pin
yaminisridaran24-Apr-08 19:49
yaminisridaran24-Apr-08 19:49 
I am trying to receive asynchronous sockets via udp but I am mostly getting WSAEWOULDBLOCK error . I anyone help me solving this problem

WSADATA wsaData;

int error = WSAStartup(0x202,&wsaData);

if(error)
return FALSE;

if(wsaData.wVersion != 0x202)
{
WSACleanup();
return FALSE;
}

m_UdpSock=(SOCKET)WSASocket(AF_INET,SOCK_DGRAM,0,NULL,NULL,0);
if(m_UdpSock==INVALID_SOCKET)
return FALSE;


sockaddr_in sockAddrServer;
sockAddrServer.sin_family=AF_INET;
sockAddrServer.sin_port=htons(port_data);
sockAddrServer.sin_addr.s_addr=INADDR_ANY;

// Bind socket to listener address
if(bind(m_UdpSock,(SOCKADDR*)&sockAddrServer,sizeof(sockaddr_in))==SOCKET_ERROR)
{
int y=WSAGetLastError();

printf("Unable to bind socket\n");
return FALSE;
}


// Create WinSock Event object
WSAEVENT eventWinsock=(WSAEVENT)WSACreateEvent();
if(eventWinsock==WSA_INVALID_EVENT)
{
printf("Unable to create winsock event\n");
return FALSE;
}

// Signal WinSock Event on receive packet
if(WSAEventSelect(m_UdpSock,eventWinsock,FD_READ)!=NOERROR)
{
printf("Unable to connect event to socket\n");
return FALSE;
}


//long length=50000;

// m_Thread=new CManager((LPVOID)this);
// m_Thread->CreateThread();

bool occurance=true;


while(m_abort)
{
Recvbuf=new char[BUFFER_SIZE];

TRACE("Before Receive Data\n");
//if(WaitForSingleObject(eventWinsock,INFINITE)== WAIT_OBJECT_0)
if(WaitForSingleObject(eventWinsock,INFINITE)== WAIT_OBJECT_0)
{
sockaddr_in sockAddrRecv;
int nSockAddrSize=sizeof(sockaddr_in);


// Packet received
EnterCriticalSection(&m_cs);
int nErr=recvfrom(m_UdpSock,Recvbuf,BUFFER_SIZE,0,(sockaddr*)&sockAddrRecv,&nSockAddrSize);
LeaveCriticalSection(&m_cs);
TRACE("Receive data\n");


if(nErr==SOCKET_ERROR)
{
TRACE("nErr %d\n",nErr);

nErr=WSAGetLastError();
if(nErr==WSAEWOULDBLOCK)
{
WSAEventSelect(m_UdpSock,eventWinsock,FD_READ);

WSANETWORKEVENTS wsevents;
WSAEnumNetworkEvents(m_UdpSock,eventWinsock,&wsevents);

DWORD dwEventId = WaitForSingleObject(eventWinsock,3000);
if(dwEventId == WAIT_TIMEOUT)
continue;
continue;

}
else
{
WSAEventSelect(m_UdpSock,eventWinsock,FD_READ);

WSANETWORKEVENTS wsevents;
WSAEnumNetworkEvents(m_UdpSock,eventWinsock,&wsevents);

DWORD dwEventId = WaitForSingleObject(eventWinsock,3000);
if(dwEventId == WAIT_TIMEOUT)
continue;
continue;

}

}

else
{
TRACE("Receive Data Size %d\n",nErr);

BYTE init=Recvbuf[0];


//EnQueue
m_Queue.SetAt(index,Recvbuf);
m_PacketSize.SetAt(index,nErr);

index++;

if(occurance)
{
DWORD dwThreadId1;
m_DeQueueThread=CreateThread(NULL,0,&Dequeue,this,CREATE_SUSPENDED,&dwThreadId1);
ResumeThread(m_DeQueueThread);
m_play->InitState=m_dequeue=true;
occurance=false;
}



}

}

}
GeneralRe: Need solution for WSAEWOULDBLOCK Pin
Mark Salsbery25-Apr-08 6:14
Mark Salsbery25-Apr-08 6:14 
QuestionWhat is the significance of #pragma once ? Pin
SherTeks24-Apr-08 19:26
SherTeks24-Apr-08 19:26 
AnswerRe: What is the significance of #pragma once ? Pin
Mukesh Kumar24-Apr-08 19:46
Mukesh Kumar24-Apr-08 19:46 
AnswerRe: What is the significance of #pragma once ? Pin
ShilpiP24-Apr-08 20:11
ShilpiP24-Apr-08 20:11 
GeneralRe: What is the significance of #pragma once ? Pin
SherTeks24-Apr-08 20:56
SherTeks24-Apr-08 20:56 
GeneralRe: What is the significance of #pragma once ? Pin
Naveen24-Apr-08 21:14
Naveen24-Apr-08 21:14 
GeneralRe: What is the significance of #pragma once ? Pin
SherTeks24-Apr-08 21:30
SherTeks24-Apr-08 21:30 
GeneralRe: What is the significance of #pragma once ? Pin
ShilpiP24-Apr-08 21:54
ShilpiP24-Apr-08 21:54 
GeneralRe: What is the significance of #pragma once ? Pin
Rajkumar R24-Apr-08 21:27
Rajkumar R24-Apr-08 21:27 
AnswerRe: What is the significance of #pragma once ? Pin
peterchen24-Apr-08 21:54
peterchen24-Apr-08 21:54 
AnswerRe: What is the significance of #pragma once ? Pin
David Crow25-Apr-08 3:45
David Crow25-Apr-08 3:45 
GeneralRunning progress bar automatically as the dialogbox is displayed Pin
Le@rner24-Apr-08 19:14
Le@rner24-Apr-08 19:14 
GeneralRe: Running progress bar automatically as the dialogbox is displayed Pin
Naveen24-Apr-08 19:24
Naveen24-Apr-08 19:24 
GeneralRe: Running progress bar automatically as the dialogbox is displayed Pin
Le@rner24-Apr-08 19:44
Le@rner24-Apr-08 19:44 
GeneralRe: Running progress bar automatically as the dialogbox is displayed Pin
Naveen24-Apr-08 19:54
Naveen24-Apr-08 19:54 
GeneralRe: Running progress bar automatically as the dialogbox is displayed Pin
Nitheesh George24-Apr-08 23:11
Nitheesh George24-Apr-08 23:11 
QuestionHow to read a property file in C++ Pin
pl_kode24-Apr-08 19:07
pl_kode24-Apr-08 19: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.