|
Hey David, if my understanding is correct, you keep receiving 0xCCCCCCCC . If it is so, you probably are plainly receiving nothing and should check recv return value.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am checking the return value, I just didn't bother putting in my code snippet. It's always 4.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Should
recv(rSocket, nData, sizeof(nData), 0);
be
recv(rSocket, (void*)&nData, sizeof(nData), 0);
You need to give recv a pointer to put the data into...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
PS - you also need to convert the received data (nData) to host byte-ordering from network byte-ordering using ntohl:
unsigned int nData;
recv(rSocket, &nData, sizeof(nData), 0);
nData = ntohl(nData);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
No matter how you swap 0xcccccccc, it always comes out the same.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Not if you do it really fast!
|
|
|
|
|
But if you implement the other fix I mentioned, you won't be getting 0xcccccccc…I didn't, anyway.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I was already using a pointer. Had I not been, the code would not have even compiled.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Well I knew only DavidCrow could solve your problem.
BTW eventually I did some test (at home, since I could not reach the server at work), using:
-
unsigned long ul = 1;
unsigned long ul = 0;
ioctlsocket(rSocket, FIONBIO, &ul);
-
unsigned long ul = 1;
ioctlsocket(rSocket, FIONBIO, &ul);
-
For all cases I got reasonable values (growing numbers, starting from 3462291165 ). What do you think about?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, September 18, 2009 4:31 PM
|
|
|
|
|
What is the difference between 1 and 2? I simply tried with and without the call to ioctlsocket() . The former failed (i.e., recv() never updated the buffer) while the latter succeeded.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
DavidCrow wrote: What is the difference between 1 and 2?
My bad, I fixed it.
What puzzles me is:
- Why on my system it works in all cases?
- Why on your system, whenever it fails, you get
4 as result of recv ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Why on my system it works in all cases?
Other than error checking, do you have any more/less code than what I've shown?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello
Can anyone tell me how to convert Julian date/time to Normal (standard) date/time
and back?
Any sample source code will help?
I do have some code, but the problem is, if the TIME is before 12 Noon, then it will
show the previous DAY.
i.e., if the actual time now is Sep 17th 10:30 AM
My code will give me the date as Sep 16th 10:30 AM
But if the current time is Sep 17th 10>30 PM
then it will give the exact day.
|
|
|
|
|
dipuks wrote: Can anyone tell me how to convert Julian date/time to Normal (standard) date/time
and back?
What is your Julian date's epoch?
Have you seen this?
What does your date/time value look like?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
what is a epoch?
am very new to julian date/time
|
|
|
|
|
dipuks wrote: what is a epoch?
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
starting from 1 january 1899 to current date
|
|
|
|
|
Ok the problem that i am having is with calculating the time...
i.e, if the time is BEFORE NOON, that is an hour value less than 12,
then the calculation gives a negative number.
when that is added with the DAY number, it actually goes back by a day.
It seems there's no perfect way of calculating the julian time if hour is less than 12?
|
|
|
|
|
Julian dates are intervals of time in days and fractions of a day since some epoch. Again, what does your Julian date look like?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i have to convert todays date into julian and then reconvert it back to normal date.
can you tell me how to do that?
|
|
|
|
|
With what information you've provided, no. Some Julian dates use Jan 1st of the current year as their epoch. Some use Jan 1st of 1970. Others use 1900. That detail alone would govern how you would convert from one to the other.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
what is julian time?
do you want to get current time and date?
if u want this, simply use this code,
CString szString;
SYSTEMTIME stTime;
GetLocalTime(&stTime);
szString.Format(_T("%02d-%2d-%02d\t%02d:%02d:%02d\tPHYSICALDRIVE %s\t %s\t%s\t\t%s\n"),
stTime.wDay, stTime.wMonth,stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond);
ok
Regards,
Srinivas
|
|
|
|
|
vasu_sri wrote: what is julian time?
Technically, it does not exist. Time, in terms of hours and minutes, is the fractional part of a day. For example, if your Julian date was 45.5, and the epoch was January 1st of the current year, that would be 12:00 on Feb 14th.
vasu_sri wrote: szString.Format(_T("%02d-%2d-%02d\t%02d:%02d:%02d\tPHYSICALDRIVE %s\t %s\t%s\t\t%s\n"), stTime.wDay, stTime.wMonth,stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond);
There are at least two things wrong with this: 1) stTime.wYear is a 4-digit year yet you are using %02d to print it; 2) You have 10 % characters in the format string yet are only passing 6 arguments. Since more items will be popped from the stack than were actually pushed onto it, an error is imminent.
That aside, where is the Julian date that you are wanting to convert?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Is it possible to swap vectors between threads using std::swap() instead of iterating one vector and copying each element (given that both vectors contain the exact same type of elements)?
For example I have a structure/vector in my CMainFrame and in my CWinThread...
const struct s_list
{
CString strTimeStamp,
strStatus,
strID,
strIPRange,
strIPAddress,
strName,
strGUID,
strOS,
strResults;
BOOL bUDPReply,
bAgent;
};
std::vector<s_list> v_list;
I am assuming it would be more efficient if I could swap the elements... The iteration/copy method works but it takes a good 30 seconds and hangs the application while its plowing through all the data.
Any ideas?
Thanks,
Rob
Whoever said nothing is impossible never tried slamming a revolving door!
|
|
|
|
|
Why swap or copy? Why not share the state? Pointer to the vector that you give to the thread.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|