Search code examples
cnetwork-programmingsend

Does send() allow you to pass an int array C


I'm trying to send an encrypted message in a simple server-client chat program.

This is the send() call:

int send(int sockfd, const void *msg, int len, int flags); 

Can I pass an int array as *msg?


Solution

  • I think you can use the send() system call. But be aware, that the len is the length of the message in bytes. So i think for an array of 5 int. You need to specify the len as 5*(sizeof(int)).

    Additionally, on the receiving side, you need to interpret it accordingly.

    As Naveen pointed out, a more detailed answer to your question is already present here.