I am used to using Java, but for our last assignment, I chose to use C++. I used CommonC++ libs.
The assignment was to make a networked X & O's game, in which 2 clints played against one another, and their communication was through a XO_server which we als had to make.
clients could view other games, start a game, join a game etc.
In other words a whole bunch of string passing.
In java, for sending a string to a socket connection is easy. The other client seems to know the when it has received the end of the string to.
with CommonC++ I had to use an explicit end of input. For example I made the last two character of everthing I sent down the pipe a " # ". (If I didn't have the space at the end of it, it the # would not show up at the other end, until I sent atleast one more char down the pipe.)
Obviosly I tried using flush(), and fooling with the buffer size (setting it to 0) etc. In the end, I had to be content to use the " # ".
This was on a win32 platform. I wish I could dig up that code (it was over a month ago) and compile it on my Linux box, to see if the same problem exists.
My questions are:
1. has anyone else experienced this? Is this a design feature or flaw, and why?
2.how could I send a binary file down a pipe? can I send a struct down a pipe?
Thanks.
~S
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am used to using Java, but for our last assignment, I chose to use C++. I used CommonC++ libs.
The assignment was to make a networked X & O's game, in which 2 clints played against one another, and their communication was through a XO_server which we als had to make.
clients could view other games, start a game, join a game etc.
In other words a whole bunch of string passing.
In java, for sending a string to a socket connection is easy. The other client seems to know the when it has received the end of the string to.
with CommonC++ I had to use an explicit end of input. For example I made the last two character of everthing I sent down the pipe a " # ". (If I didn't have the space at the end of it, it the # would not show up at the other end, until I sent atleast one more char down the pipe.)
Obviosly I tried using flush(), and fooling with the buffer size (setting it to 0) etc. In the end, I had to be content to use the " # ".
This was on a win32 platform. I wish I could dig up that code (it was over a month ago) and compile it on my Linux box, to see if the same problem exists.
My questions are:
1. has anyone else experienced this? Is this a design feature or flaw, and why?
2.how could I send a binary file down a pipe? can I send a struct down a pipe?
Thanks.
~S