Receive binary file through recv

From: michelle (theintangible1_at_hotmail.com)
Date: 06/25/03


Date: 24 Jun 2003 15:19:11 -0700

Hi, I am trying to send a binary file from the client to the server.
On the client side, I have the file that I want to send to be stored
in a buffer, (array of bytes), and on the server side, I wonder when I
receive it, instead of allocate a buffer could I create a file and set
the parameter ptr in recv() to the file descriptor of the newly
created file? But either way it didn't work, and my code is
following, can someone tell me what I did wrong? Thanks!

Directly recv to file:
fid=fopen("testing", "w");
bytes=recv(clisock, fid, length, 0);

Recv to buffer then write to file:
char *buf=(char *)malloc(length*sizeof(char); (length is how many
bytes of data)
fid=fopen("testing", "w");
bytes=recv(clisock, buf, length, 0);
fwrite(buf, 1, length, fid); (the data is in unit of bytes)
fclose(fid);



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Synchronizing "pushed" multicasts
    ... The buffer just compensates for variations in the transport service. ... You can't simply push packets to the client at a constant rate - you ... server knows or the flow control protocol can specify the burst limit. ... audio hardware clock doesn't support fine-grained adjustment). ...
    (comp.arch.embedded)
  • Re: UCX connect function timeout
    ... This is an example of a VMS client program communicating with ... In this example the T3_DEMO server is listening on port 1024 at node ... The Access Control Information buffer must be the first buffer transmitted ... the communication server. ...
    (comp.os.vms)
  • Re: out param question
    ... even though the server side set's the pSize on the way out, ... it back to the client, ... the client would free the buffer ... ... what IDL am i looking for here? ...
    (microsoft.public.win32.programmer.ole)
  • Re: Buffersize for Socket.Recieve() method
    ... > i have a problem with the buffer size at the client. ... > Server -> Server sends 100 bytes of data ... oder ebenso mit vorherigen/nachfolgenden Daten kombiniert [zB Recv liefert 110 Bytes aufs mal]. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)