 <p>Simple:</p> <pre><code>int my_int = 1234; send(socket, &amp;my_int, sizeof(my_int), 0); </code></pre> <p>The above code sends the integer <em>as is</em> over the socket. To receive it on the other side:</p> <pre><code>int my_int; recv(socket, &amp;my_int, sizeof(my_int), 0); </code></pre> <p>However, be careful if the two programs runs on systems with different byte order.</p> <p><strong>Edit:</strong> If you worry about platform compatibilities, byte ordering and such, then converting all data to strings on one end and then convert it back on the other, might be the best choice. See e.g. the answer from cnicutar.</p>