Difference between recv and read, send, and write

1

I'm transmitting and collecting data from a connection using Sockets , to send the data to the served, you can use the send and write commands, and to receive the data recv and read .

  • Is there a difference in these commands?

  • What advantage / disadvantage can you have in using send or write to send some data?

  • What advantage / disadvantage can you have in using recv or read to receive some data?

asked by anonymous 22.11.2016 / 18:11

1 answer

1

Send

Both clients and servers use send to transmit data. Typically, a client sends a request and the server sends a response.

Recv

Both clients and servers use recv to get data that has been sent by the other.

Read and Write

On some operating systems, such as Linux, read and write functions can be used instead of recv and send .

Read and Write Advantage The great advantage of using read and write is generalization - an application can be created with the purpose of transferring data to or from a descriptor without knowing if it corresponds to a file or a socket . In this way, a programmer can use a file on the local disk to test a client or server before attempting to communicate over the network.

Read and write disadvantage The program loses portability when compiled on another operating system.

Source 01 : Computer Network and Internet - 6 ed. Douglas E. Eating Font 02 : link

    
22.11.2016 / 18:38