Click here to Skip to main content
15,921,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WM_KILLFOCUS / WM_SETFOCUS Pin
Ryan Binns14-Feb-05 12:15
Ryan Binns14-Feb-05 12:15 
GeneralRe: WM_KILLFOCUS / WM_SETFOCUS Pin
PJ Arends14-Feb-05 20:56
professionalPJ Arends14-Feb-05 20:56 
GeneralRe: WM_KILLFOCUS / WM_SETFOCUS Pin
Ryan Binns14-Feb-05 22:57
Ryan Binns14-Feb-05 22:57 
GeneralAnimateWindow & OnPaint problem Pin
Anonymous13-Feb-05 8:49
Anonymous13-Feb-05 8:49 
Generalrun-time dll linking - getting a variable Pin
Kuniva13-Feb-05 8:18
Kuniva13-Feb-05 8:18 
GeneralRe: run-time dll linking - getting a variable Pin
Neville Franks13-Feb-05 9:43
Neville Franks13-Feb-05 9:43 
GeneralRe: run-time dll linking - getting a variable Pin
Kuniva13-Feb-05 12:40
Kuniva13-Feb-05 12:40 
GeneralUDP sockets -> select() not working .. Please HELP! Pin
Member 172877313-Feb-05 7:51
Member 172877313-Feb-05 7:51 
Hi,

If someone has the answer to this I will be most greatful. I cannot get the select() function to work here. My program successfully sends the message and the server responds to this message(I have seen the results on ethereal). What I am trying to accomplish is send out a UDP message(the one defined by RequestStatMsg(which is properly formatted and correct and works fine)), then use the select function as shown below to simply listen for a reply for one second, and log if there is a reply, then repeat. The idea is to test a device to see if it responds to this UDP status request message promptly, and to log failures...testing over long durations(days). This is driving me mad. Thank you for any input you may provide!!

CODE

//Global

typedef struct{
unsigned short MsgID; /* REQUEST_STAT_MSG (0x00) */
unsigned short MsgSize; /* Bytes in this message */
}RequestStatMsg;


SOCKADDR_IN remote; // For client
SOCKET sock; // For client
SOCKADDR_IN RecvAddr; // "server usage on PC side"
SOCKET RecvSocket; // for recieving the Stat request message

struct timeval stTimeOut; // Create the timestruct for the

fd_set stReadFDS; // Set the file descriptors
fd_set stXcptFDS;
.
.
.
// everything else isinside <int cjtf_appdlg::onsend()="">
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
RecvSocket = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP);
.
.
.
while(true)
{
// the sendto works fine
sendto(sock, (char *)&ReqStatMsg,sizeof(ReqStatMsg),
0,(SOCKADDR *)&remote, sizeof(SOCKADDR));

StatMsgSent++;
TempStr.Format("%d", StatMsgSent);
m_MsgSentCnt.SetWindowText(TempStr);

stTimeOut.tv_sec= 1; // 1 sec timeout
stTimeOut.tv_usec=0; // use for milliseconds

// Bind the socket to RED SIDE and the specified port.
RecvAddr.sin_family = AF_INET;
RecvAddr.sin_port = htons(prt); //
RecvAddr.sin_addr.s_addr = inet_addr(IPAddrStr);

bind(RecvSocket, (SOCKADDR *) &RecvAddr,
sizeof(RecvAddr));

// Prep the members
FD_ZERO(&stReadFDS);
FD_ZERO(&stXcptFDS);
FD_SET(RecvSocket, &stReadFDS);
FD_SET(RecvSocket, &stXcptFDS);

// set up to for 1 second
retvalue = select(0,&stReadFDS, NULL, NULL, &stTimeOut);

// handle the case that no message is available
through(timeout 1sec)
// else receive the message
recvfrom(RecvSocket,RecvBuf,BufLen, 0,(SOCKADDR*)
&SenderAddr, &SenderAddrSize);

// This ALWAYS times out after one second, but I know the response is coming back(ethereal). The server simply responds to the clients ip address and port that it sent from. I'm not getting it though???
Thank you in advance for your help!

Rich
QuestionGetting size of file? Pin
Moochie513-Feb-05 7:48
Moochie513-Feb-05 7:48 
AnswerRe: Getting size of file? Pin
Ravi Bhavnani13-Feb-05 8:29
professionalRavi Bhavnani13-Feb-05 8:29 
GeneralRe: Getting size of file? Pin
Neville Franks13-Feb-05 9:38
Neville Franks13-Feb-05 9:38 
AnswerRe: Getting size of file? Pin
David Crow14-Feb-05 3:51
David Crow14-Feb-05 3:51 
GeneralRe: Getting size of file? Pin
Moochie514-Feb-05 16:24
Moochie514-Feb-05 16:24 
GeneralRebar problems! Pin
Temuri13-Feb-05 6:38
Temuri13-Feb-05 6:38 
GeneralRe: Rebar problems! Pin
Neville Franks13-Feb-05 9:57
Neville Franks13-Feb-05 9:57 
GeneralRe: Rebar problems! Pin
Temuri13-Feb-05 20:19
Temuri13-Feb-05 20:19 
GeneralRe: Rebar problems! Pin
Neville Franks13-Feb-05 20:29
Neville Franks13-Feb-05 20:29 
GeneralRe: Rebar problems! Pin
Temuri13-Feb-05 21:40
Temuri13-Feb-05 21:40 
GeneralRe: Rebar problems! Pin
Neville Franks14-Feb-05 9:29
Neville Franks14-Feb-05 9:29 
GeneralSQLConnect With Custom ODBC Driver Pin
KalliMan13-Feb-05 6:06
KalliMan13-Feb-05 6:06 
QuestionHow to read/write an object of MyClass from/to a file. Pin
six_billion13-Feb-05 5:59
six_billion13-Feb-05 5:59 
AnswerRe: How to read/write an object of MyClass from/to a file. Pin
KalliMan13-Feb-05 6:12
KalliMan13-Feb-05 6:12 
GeneralRe: How to read/write an object of MyClass from/to a file. Pin
six_billion14-Feb-05 5:21
six_billion14-Feb-05 5:21 
AnswerRe: How to read/write an object of MyClass from/to a file. Pin
Ravi Bhavnani13-Feb-05 8:30
professionalRavi Bhavnani13-Feb-05 8:30 
AnswerRe: How to read/write an object of MyClass from/to a file. Pin
six_billion13-Feb-05 16:42
six_billion13-Feb-05 16:42 

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.