Like Tree1Likes

c socket send int instead of a char array

This is a discussion on c socket send int instead of a char array within the C Programming forums, part of the General Programming Boards category; Okay, the code you posted doesn't look like it has any problems. Please post the smallest client and server programs ...

  1. #16
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,676
    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
    52
    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

Page 2 of 2 FirstFirst 12
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, 03: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, 07: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21