Forum: C++ Sep 21st, 2009 |
| Replies: 3 Views: 407 Post padding isn't the optimal solution. Pre-padding is!
Do a 32 bit write each write no loop!
unsigned char vect2enc[4][32];
uint32 *pAry = (uint32 *) vect2enc;
*(pAry+0) = 0;
*(pAry+1) =... |
Forum: C++ Sep 14th, 2009 |
| Replies: 1 Views: 342 I like using IOCP I/O completion Ports. Works very nicely for minimal threads to maintain thousands of sockets!
Works well for only a couple sockets as well! Its a worker thread to event manager.... |
Forum: C++ Aug 27th, 2009 |
| Replies: 2 Views: 233 Debug run vs Release not run is quite often an initialization error. Memory typically isn't initialized in Release. Your constructor shold initialize your data members to a known good value. Before... |
Forum: C++ Aug 13th, 2009 |
| Replies: 19 Views: 485 nProduct = 1
for (int i = 0; i < 4; i++)
input v
if ((v > 4) && !(v & 1))
nProduct = nProduct * v;
endif
endfor
if (1 ==nProduct) then error |
Forum: C++ Aug 13th, 2009 |
| Replies: 19 Views: 485 nProduct = 1
for (int i = 0; i < 4; i++)
if ((ary[i] > 4) && !(ary[i] & 1))
nProduct = nProduct * ary[i];
endif
endfor
if (1 ==nProduct) then error |
Forum: C++ Aug 13th, 2009 |
| Replies: 4 Views: 210 can you make a text picture! |
Forum: C++ Aug 13th, 2009 |
| Replies: 4 Views: 210 Which terminal he will put his PC ?
Are there 20 pre-existing x,y coordinates or are you setting the coordinate for each terminal you say exist?
This is a form of path traversal. This can be... |
Forum: C++ Aug 13th, 2009 |
| Replies: 5 Views: 373 Enum math isn't available so you have to do a work around.
You have to use integers for the loop, but cast it into the enum!
for( int i = first_location; i <= last_location; i++)
{
... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 good luck however if the server was written properly, the client is merely a playback. It can only request things of the server and its the servers job to validate a message, detect an invalid... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 You do not send (-) or 0 bytes! You need to only relay if bytes received is (> 0).
As to an error, you need to handle different errors appropriately. |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 Okay the Python code uses two threads. One deals with catching and relaying. The other the returned data.
The question now comes, which has been tickling at me, why are you trying to intercept... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 4,294,967,295
0xffffffff (-1)
Check the error!
Sounds like you don't have your second connection between proxy and Host established!
let's see your code again! |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 There are different socket type protocols. Do you know what protocol the source and destination sockets are communicating with? Based upon the data you're seeing it doesn't look encrypted!
You're... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 You are acting as a proxy and relaying packets. Do you have a message specification that describes the format of the messages? You can teach your program that format so it is more aware of what it is... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 You received a packet length, send the whole packet back! If their code is written properly they should be able to parse the bundled messages.
OR you know what the lead tag is, build a parser to... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 decimal value (0) is not a printable character! And negative characters are a problem.
The code has scrolled of the display but change
void printfunction( char * buffer, int size )
{
... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 Interesting. YOu have a fixed header,
contains
'S','A','M','P',127,0,0,1 ';', 5 Then a letter code
70 'p' contains four more bytes
69 'i'
63 'c'
72 'r' |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 If you have compile issues just modifiy this code block or remove it!
#if 0
if ( NULL != szText ) { char buff[ LOG_BUF_MAX ]; va_list args; va_start( args, szText ); vsprintf(buff, szText,... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 You are printing decimal codes for 127 0 0 1.
That normally isn't sent as a message! So either something is wrong with the sender, or those particular bytes are suppose to have the IP address within... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 This is a handy function to keep around. I have it embedded in my file logging system.
Use it to dump your incoming buffer.
I've twiddled it for the post and replace RawPrint as your cout or... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 Do you have a raw dump of what's being sent!
Did you catch my last second buffer posting of 1024 vs 10240.
)(127)(0)(0)(1)
127.0.0.1
Is someone sending the Local IP as text! |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 1st check that buffer length!
int fromlen = 10240; Your buffer is char buff[ 1024 ] not 10240.
that shouldn't be your problem but it is a problem!
Do a zero check!
Returning a vaue of zero... |
Forum: C++ Aug 12th, 2009 |
| Replies: 5 Views: 262 Not a problem. As I mentioned the table lookup only works out if a sequential set of enums is used. Then the case statement is the better selection.
Having posted here, means trying to teach about... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 Yes! That's the number of bytes received in the packet. Packets aren't cut in half, they are delivered whole! So your packet will contain one or more messages! |
Forum: C++ Aug 12th, 2009 |
| Replies: 5 Views: 262 No need for a case statement. Since you have an enum table and if they use the default sequencing equate 0, 1, 2, etc. then use an ASCII table lookup that matches 0 based enum to table index. ... |
Forum: C++ Aug 12th, 2009 |
| Replies: 50 Views: 1,880 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... |
Forum: C++ Aug 12th, 2009 |
| Replies: 5 Views: 373 If this is a duplicate forgive me. I posted but it didn't show up!
This is a mistake! It's in two places in your code!
// for(i = first_location; i <= last_location; i+1)
... |
Forum: C++ Aug 12th, 2009 |
| Replies: 8 Views: 428 If you aren't interested in building electronics projects that involve programming and embedded microprocessors with digital electronics designs then stick with the Software Engineering.
Almost... |
Forum: C++ Aug 12th, 2009 |
| Replies: 19 Views: 485 A for loop is like a while loop, note the components below
for (int m = 0; m < 4; m++ )
int m = 0;
while ( m < 4 )
{
m++ } |
Forum: C++ Aug 12th, 2009 |
| Replies: 3 Views: 1,639 Yes. bool was added to the C++ specification in a later release.
However bool is a loose specification within Visual Studio. It allows you to assign other values then bool true false. If I'm... |
Forum: C++ Aug 12th, 2009 |
| Replies: 8 Views: 428 Good for you. Stay on Honors Science and Math all the way through High School, get your Calculus and Physics wrapped up so you can slide right into a University Engineering program. You'll then need... |
Forum: C++ Aug 12th, 2009 |
| Replies: 8 Views: 428 You don't say where you are in High School but hopefully you are in Honors classes because without them you'll be on the Community College tract. Times change. In the early days of programming you... |
Forum: C++ Aug 11th, 2009 |
| Replies: 5 Views: 871 here's a leg up....
if (low > high)
{
long t = low;
low = high;
high = t;
} |
Forum: C++ Aug 10th, 2009 |
| Replies: 3 Views: 277 Easy, End of File condition. Bytes may be in the buffer but an EOF occured.
Make sure the last line doesn't have the EOF! Or special handling. |
Forum: C++ Aug 10th, 2009 |
| Replies: 4 Views: 287 Pieces don't need a color. They do need an identifier to indicate which color they are. A single bit would do. bit=1:White 0:Black
All piece go in all directions except for pawns which are... |
Forum: C++ Aug 10th, 2009 |
| Replies: 4 Views: 287 Pawns only go forward. if they aren't in their home row, they've moved!
if that's a problem, put a move counter on them.
If count=0, they haven't moved. Even a bit will do the job! |
Forum: C++ Aug 10th, 2009 |
| Replies: 18 Views: 726 Okay, I'm confused. I'm assuming you're debugging up first and so that's why only 'w' is supported.
do{
cin >>numsquare;
if ((ro-numsquare) < 0 )
cout <<"The number of square is not in... |
Forum: C++ Aug 10th, 2009 |
| Replies: 6 Views: 990 You appear to need unique numbers but you are generating non-unique numbers.
You have a 2x4, unique numbers in the upper 2x2 and another unique set in the lower unique 2x2. So generate the top... |
Forum: C++ Aug 10th, 2009 |
| Replies: 3 Views: 570 Something like this?
typedef float (*psraBProc)( int x );
float psraBFunc( int x )
{
}
int r; |
Forum: C++ Aug 9th, 2009 |
| Replies: 3 Views: 334 You didn't follow your own instructions
//Write the defintion of function one so that it returns the sum of x and y if x greater than y, it sholud return x mines 2 times y.
int one (int x, int y)... |