| | |
Terminating Zero Problem
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
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:
Check if bytesReceived is the correct number of bytes you want to recieve.
not contain what you want.
I assume that the problem is here:
C++ Syntax (Toggle Plain Text)
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?
•
•
Join Date: Aug 2009
Posts: 32
Reputation:
Solved Threads: 0
when I do
It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?
C++ Syntax (Toggle Plain Text)
void filter(char* packet) { for(int i = 0; i < 8; i++) { cout << "(" << int(*packet) << ")"; packet++; } cout << endl; }
It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?
"will evaluate to false when packet[i]==0"
Yes thats correct. The 0 identifies the end of the string. Any further
then its junk.
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?
•
•
•
•
when I do
C++ Syntax (Toggle Plain Text)
void filter(char* packet) { for(int i = 0; i < 8; i++) { cout << "(" << int(*packet) << ")"; packet++; } cout << endl; }
It print's
(83)(65)(77)(80)(127)(0)(0)(1)
though, so that would mean the buffer contains that information right?
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?
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!
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!
C++ Syntax (Toggle Plain Text)
void filter( char* packet, uint nPacketLen ) { while (nPacketLen) { while ((*packet != 0) && nPacketLen) { cout << "(" << int(*packet) << ")"; packet++; nPacketLen-- } cout << endl; } }
Last edited by wildgoose; Aug 12th, 2009 at 2:39 pm.
![]() |
Similar Threads
- problem with passing dynamic links (C)
- OUTPUT problem (C++)
- Tubo C strange problem (C)
- IE 6 problem with .innerHTML (JavaScript / DHTML / AJAX)
- Input Stream Problem (C++)
- Problem with "getline(cin, name)" (C++)
- problem with output values (Assembly)
- Need help with signals problem please... (C)
- A small problem in the output (C++)
Other Threads in the C++ Forum
- Previous Thread: sequence diagram help
- Next Thread: how to derive class from a derived class
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






