TCP client in Java and server in C
<p>I would like to make a chat application. The client will be written with java and the server will be written with C. On the server side, the message will be sent as struct. On the client side, how do I read and separate the message with Java?</p>

<p><strong>Here is a sample packet structure:</strong></p>

<pre><code>struct s_packet{
 int   text_color;
 char  text[TEXTSIZE];
 char  alias[ALIASIZE];
};
</code></pre>

<p><strong>Here is a sample server(in C) send function:</strong></p>

<pre><code>send(iter-&gt;client.sockfd, (void *)se_packet, sizeof(s_packet), 0);
</code></pre>

<p><strong>Here is a sample client recv function in C:</strong></p>

<pre><code>recv(m_sockfd, (void *)&amp;se_packet, sizeof(s_packet),0);

printf("\x1b[3%dm &lt;%s&gt;: %s \x1b[0m\n", se_packet.text_color, se_packet.alias, se_packet.text);
</code></pre>

<p>I can read s_packet and separate in C, but How can I do it in java?</p>

<p>How can i separate like that in Java:</p>

<pre><code>printf("\x1b[3%dm &lt;%s&gt;: %s \x1b[0m\n", se_packet.text_color, se_packet.alias, se_packet.text);
</code></pre>