Thread: TCP Programming problems with recv

  1. #1
    Registered User
    Join Date
    Sep 2002

    TCP Programming problems with recv


    I am learning how to program a TCP server and have a problem.

    I get everything up and running and I can connect to the server and the server can send information out to the client fine.

    The problem I have now though is that I'd like to know how to tell the server to prompt the user to enter information (aka commands). I have tried the recv(socket, buffer, bufferlength, flags) approach but I think I don't know the right flags (I'm trying '0')to use because I can only recieve one letter, after that theres a big string of symbols.

    Any help as to how I can get strings and no jibberish would be most appreciated, as always.


  2. #2
    Registered User
    Join Date
    Sep 2002
    This is what I have:

    sprintf(ClientOutput,"Please type something: ");
            char ClientInput[1000];
            recv(SOCKET1,ClientInput,1000,2);          // Get stuff by the client
            cout << ClientInput;                // Output it to the server
            send(SOCKET1,ClientInput,strlen(ClientInput),0);     // Output it back to the client
    When the user types something it is supposed to echo it back to them. But It only lets them type one character. It then has that character as the first character of the string and then adds about 7-10 other symbols to the end of that string.

    Im using Borland C++Builder v3 (Old I know) and Windows 98.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TCP Header problem (error)
    By nasim751 in forum C Programming
    Replies: 1
    Last Post: 04-25-2008, 07:30 AM
  2. Accessing TCP flags in TCP packets on Linux using C !!
    By vishamr in forum Linux Programming
    Replies: 2
    Last Post: 10-16-2006, 08:48 AM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  4. Huge problems in Winsock recv!
    By sirSolarius in forum Networking/Device Communication
    Replies: 0
    Last Post: 09-11-2004, 09:34 AM
  5. TCP TIME_WAIT state
    By Engineer in forum A Brief History of
    Replies: 1
    Last Post: 12-27-2001, 08:50 AM