Thread: Socket communication hanging

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    A better way to read in a file and send it would be like this:
    Code:
    {
      char file[MAXDATASIZE];
    
      while(fgets(file, sizeof(file), local_file))
      {
        if(feof(local_file))
          break;
        printf("%s", file);
        write(socket, file, strlen(file));
      }
    }
    This is of course assuming it's always a text file you're sending.
    Last edited by itsme86; 08-05-2004 at 04:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  2. when to close a socket
    By Wisefool in forum Networking/Device Communication
    Replies: 5
    Last Post: 11-02-2003, 10:33 AM
  3. problem closing socket
    By Wisefool in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-29-2003, 12:19 PM
  4. problem closing a socket
    By Wisefool in forum C Programming
    Replies: 1
    Last Post: 10-28-2003, 01:38 PM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM