Thread: c socket send int instead of a char array

  1. #16
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Okay, the code you posted doesn't look like it has any problems. Please post the smallest client and server programs you can create that produce this problem.

    EDIT: Please also show the command you use to compile, any output from the compiler, and any instructions or data files we need to replicate the problem.

  2. #17
    Registered User
    Join Date
    May 2012
    Location
    Italy
    Posts
    53
    I've found the bug The problem was that i had a
    Code:
    recv(f_sockd, buf, sizeof(buf), 0);
    where buf is
    Code:
    char buf[256]
    but the real received buf was only 5 chars!
    So i have changed the above instruction to:
    Code:
    recv(f_sockd, buf, 6, 0);
    and now all works perfectly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. socket send
    By Drogin in forum Networking/Device Communication
    Replies: 8
    Last Post: 11-19-2009, 07:44 AM
  2. Socket Send
    By anne_kleyheeg in forum C Programming
    Replies: 3
    Last Post: 08-13-2009, 02:20 PM
  3. How Do I Send a Two-Dimensional Char Array to a Function?
    By DonFord81 in forum C Programming
    Replies: 7
    Last Post: 02-26-2009, 03:01 AM
  4. Send and Int Through Socket?
    By BENCHMARKMAN in forum C Programming
    Replies: 2
    Last Post: 03-16-2008, 06:58 AM
  5. Socket Send Help
    By cloudy in forum Networking/Device Communication
    Replies: 2
    Last Post: 11-13-2007, 04:17 PM

Tags for this Thread