Thread: Why the simple Socket Snippet doesn't work?

  1. #1
    Registered User
    Join Date
    Apr 2007

    Why the simple Socket Snippet doesn't work?

    Sender side:
    int len = strlen(str);
    Receiver Side:
    int len;
    char* str=(char*)malloc(len*sizeof(char));

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    what are return values of write and read?
    what does it mean - "doesn't work" - how do you check it?

    PS. And this is C, why to post on C++ board?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    maybe because write() and read() aren't part of the socket API !?

    also, what OS? I don't see any of the initialization or setup functions in that snippet. without some more context information it could be anything, a bad pointer, a bad socket, unitialized socket stack, improperly installed drivers, poor feng shui, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program won't work on a friend's comp
    By Ouendanation in forum C++ Programming
    Replies: 6
    Last Post: 01-25-2008, 08:03 PM
  2. Replies: 7
    Last Post: 11-15-2007, 01:36 AM
  3. Novice Beginner: Simple hello world wont work
    By hern in forum C++ Programming
    Replies: 8
    Last Post: 06-25-2005, 12:16 PM
  4. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  5. when to close a socket
    By Wisefool in forum Networking/Device Communication
    Replies: 5
    Last Post: 11-02-2003, 10:33 AM