cherryhouse

Members
  • Content count

    277
  • Joined

  • Last visited

Community Reputation

100 Neutral

About cherryhouse

  • Rank
    Member
  1. I would have to say once you've thought about the program logic yourself. This might just be me, but if I programmed the same program as someone else, with maybe a few slight differences, I would want to call it my code since I did think about it all myself, someone just happend to make the same thing. Unfortunately, that would only mean(to you) that it's your code, depending on who released the program first.
  2. simpel c++

    Is your book for learning or is it just excercizes? If it's only little programming challenges, maybe you should buy a beginner C++ book. If it has explainations, maybe you should read them before attempting the excersize.
  3. I Love This Place :')

    Quote:Original post by Prinz EugnBut I have to say that for the most part people are very respectful and do not rate down those that dissagree with them, and often debates end up with both sides learning something, even if no consensus on the issue is reached. I disagree. I've rarely made posts disagreeing with people(aside from this one and some others...) and yet I've have my rating decreased an unfair amount. I don't use the rating system or even really pay attention to it though so I won't make a deal out of it. The forums are lovely by the way.
  4. simpel c++

    If you knew about loops and character arrays(char's), you probably wouldn't need our help anymore. You said you have a book, so USE IT!
  5. Do you play too many video games?

    Does 0/gph count as "too many"? gph == games per hour
  6. Leftovers, MMmmm...

    Ok, so I'm attempting to take my last look at buffer "leftovers" as a problem. I'm trying to deal with sending ip's over a network, dynamic ips. That means I need to be able to send an 11 character ip, 15 character ip, then 13 character ip. The problem I'm having is whenever i request to see my ip with my command "-ip"(doesn't really matter but whatever), the output is as such: Quote:192.168.1.1 2.168.1. there is apparently 19 characters(20 including '\0' character?), so what I'm thinking is that the client is requesting more data than I want it to, causing the server to send the extra "2.168.1." off the first ip. Here's what I have: //server recv cmd void Server::Recv_msg() { // Receive buffer on character array recvbuf if ((bytes = recv(i, recvbuf, 10, 0)) <= 0) { // If no data received, remove client from userlist Remove_client(); }else if(!strcmp(recvbuf, "-ip")){ for(int h = 0; h < my_vec.size(); h++){ tempuser2 = my_vec.at(h); if(tempuser2.name=="client") for(j = 0; j <= fdmax; j++) { // if socket j is in the set, send to that socket if (FD_ISSET(j, &master)) { // Send recvbuf to all users send(j, tempuser2.ip.c_str(), strlen(tempuser2.ip.c_str()), 0); } } } }else{ // If data was received, send to all users Send_msg(); // Doesnt matter to us though } } //client recv void Client::RecvMessage() { // sockfd: Socket in which data is received // recvbuf: Char in which data is received (as a string) // 256: Max bytes to receive from the server while (bytes = recv(sockfd, recvbuf, 10, 0) == -1) // Output error message if error occurs { Msges.ErrorMsg("Error while receiving."); } myLog.open(logname.c_str(), ios::app); myLog << recvbuf; myLog.close(); cout << recvbuf; } I know the problem is with the client receiving because he won't always receive 10 bytes of data. This is what I'm trying to figure out.
  7. ascii - int to character

    well, Apparently, when I receive the string it ends up looking like so: " 6 5 " I don't even know how I can pick apart this string so that it's simply "65", so I think I'll just leave this alone for now.
  8. ascii - int to character

    The constructor does necessary "nullifying" to char recvbuf[5]; Client::Client(){ for(int i = 0; i <= 5; i++) recvbuf[i] = '\0'; } The sending looks like this /*move the ascii decimal value into a string to send over the network */ itoa(i, newb, 10); client.SendMessage(newb); void Client::SendMessage(char* set_msg) { // sockfd: Socket in which data is sent through // buf.c_str(): String in which data is sent from // bufsize: Amount of bytes to send (value == size of buf) if (bytes = send(sockfd, set_msg, 5, //perhaps i'm sending too many bytes? 0) == -1) // If error occurs, exit program { return exit(1); } }
  9. Could I be pointed out the problem with this code? I've tested the network to make sure the correct integers are being sent over the network, and they are, so why isn't the client doing its job of converting the integer to a character? while (bytes = recv(sockfd, recvbuf, 4, 0) == -1) // Output error message if error occurs { Msges.ErrorMsg("Error while receiving."); return exit(1); } switch(atoi(recvbuf)) { case 43 : cout << '+'; break; default: break; }
  10. Console or Windows App?

    console vs gui barely makes a difference on modern computers. It's what's going on behind the scenes that causes slow-down.
  11. sending... sending... stop.

    Wow, I can't believe I didn't see it before... I feel like an idiot :(. send(j, recvbuf, sizeof(recvbuf), 0); I don't think I have to explain the problem to anybody. Thanks for all the help.
  12. sending... sending... stop.

    TCP_NODELAY didn't make a difference in this case. It's such a simple thing but I still don't know what's happening, ugh.
  13. sending... sending... stop.

    I'm thinking about making the switch over to udp(even though it's quite...ridiculous)seeing that my server seems to get hung up on single packets being sent and lost in a loop.
  14. Programmers that can't do shit

    The people you're talking about are the people who get the assignment and first 5 seconds of having it, post all over every programming forum they know for the answers.
  15. Need help in programming!!!!

    My guess is that the book you have doesn't take you through the basics and I'm going to take a wild guess and say you haven't learned the basics. You should put your book down for now, find a "Beginning programming" book, read it, understand it, then move on to your game book. It will be a lot easier to understand the game programming book and find/fix problems like the one you're having now.