Terminating Zero Problem

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2009
Posts: 17
Reputation: harry010 is an unknown quantity at this point 
Solved Threads: 2
harry010 harry010 is offline Offline
Newbie Poster

Re: Terminating Zero Problem

 
0
  #11
Aug 12th, 2009
never mind what i'm saying
Last edited by harry010; Aug 12th, 2009 at 2:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 32
Reputation: Schoorsteen is an unknown quantity at this point 
Solved Threads: 0
Schoorsteen Schoorsteen is offline Offline
Light Poster

Re: Terminating Zero Problem

 
0
  #12
Aug 12th, 2009
That still doesn't work, it prints the first 5 characters, but not the following characters.

Currently it prints
(83)(65)(77)(80)(127)
which means:
SAMP and the 127 is the start from my local IP, which should be (127)(0)(0)(1).
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,256
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 155
firstPerson's Avatar
firstPerson firstPerson is online now Online
Nearly a Posting Virtuoso

Re: Terminating Zero Problem

 
0
  #13
Aug 12th, 2009
Then your problem is the buffer thats being passed to it. I does
not contain what you want.

I assume that the problem is here:
  1. bytesReceived = recvfrom(incs.cl, buffer, 1024, 0, (struct sockaddr *)&clSockAddr, &fromlen);

Check if bytesReceived is the correct number of bytes you want to recieve.
Last edited by firstPerson; Aug 12th, 2009 at 2:14 pm.
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e, Paul Thompson]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...[*]
      [*solved by : murtan]
3) What is the 123456789 prime numer?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: harry010 is an unknown quantity at this point 
Solved Threads: 2
harry010 harry010 is offline Offline
Newbie Poster

Re: Terminating Zero Problem

 
0
  #14
Aug 12th, 2009
Sorry, i shouldn't be trying to answer this-I'm just confusing things with my nonsense responses.
Last edited by harry010; Aug 12th, 2009 at 2:19 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 32
Reputation: Schoorsteen is an unknown quantity at this point 
Solved Threads: 0
Schoorsteen Schoorsteen is offline Offline
Light Poster

Re: Terminating Zero Problem

 
0
  #15
Aug 12th, 2009
when I do
  1. void filter(char* packet)
  2. {
  3.  
  4. for(int i = 0; i < 8; i++)
  5. {
  6. cout << "(" << int(*packet) << ")";
  7. packet++;
  8. }
  9.  
  10. cout << endl;
  11. }

It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,256
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 155
firstPerson's Avatar
firstPerson firstPerson is online now Online
Nearly a Posting Virtuoso

Re: Terminating Zero Problem

 
0
  #16
Aug 12th, 2009
"will evaluate to false when packet[i]==0"

Yes thats correct. The 0 identifies the end of the string. Any further
then its junk.
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e, Paul Thompson]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...[*]
      [*solved by : murtan]
3) What is the 123456789 prime numer?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 32
Reputation: Schoorsteen is an unknown quantity at this point 
Solved Threads: 0
Schoorsteen Schoorsteen is offline Offline
Light Poster

Re: Terminating Zero Problem

 
0
  #17
Aug 12th, 2009
When I cout the receivedBytes I get this number 4294967295. Would this be right?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: harry010 is an unknown quantity at this point 
Solved Threads: 2
harry010 harry010 is offline Offline
Newbie Poster

Re: Terminating Zero Problem

 
0
  #18
Aug 12th, 2009
Originally Posted by firstPerson View Post
"will evaluate to false when packet[i]==0"

Yes thats correct. The 0 identifies the end of the string. Any further
then its junk.
Sorry, I didn't understand the original post at first. I shouldn't have posted anything.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,256
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 155
firstPerson's Avatar
firstPerson firstPerson is online now Online
Nearly a Posting Virtuoso

Re: Terminating Zero Problem

 
0
  #19
Aug 12th, 2009
Originally Posted by Schoorsteen View Post
when I do
  1. void filter(char* packet)
  2. {
  3.  
  4. for(int i = 0; i < 8; i++)
  5. {
  6. cout << "(" << int(*packet) << ")";
  7. packet++;
  8. }
  9.  
  10. cout << endl;
  11. }


It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?
Thats weird. Try cout<<buffer before the function call , and in the function as well. See if they are the same.
Last edited by firstPerson; Aug 12th, 2009 at 2:24 pm.
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e, Paul Thompson]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...[*]
      [*solved by : murtan]
3) What is the 123456789 prime numer?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Terminating Zero Problem

 
1
  #20
Aug 12th, 2009
I think you're all missing the point. Sockets doesn't send immediately.

Send Packet 5
Send Packet 8
Send Packet 7

It won't necessarily arrive as three packets 5 then 8 then 7 bytes in length.
It may arrive as 2 packets 5+8=13 and 7
or 5 and 15
or a single packet 20 bytes long!
The packet is sent on an interval basis, not immediately so sometimes packets get combined as a single packet of multiple messages!

So instead!
  1. void filter( char* packet, uint nPacketLen )
  2. {
  3. while (nPacketLen)
  4. {
  5. while ((*packet != 0) && nPacketLen)
  6. {
  7. cout << "(" << int(*packet) << ")";
  8. packet++;
  9. nPacketLen--
  10. }
  11. cout << endl;
  12. }
  13. }
Last edited by wildgoose; Aug 12th, 2009 at 2:39 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC