title: Proper way to create packets along with sending and receiving them in socket programming using C
body: <p>I had written a small client-server code where in I was sending integers and characters from my client to server. So I know the basics of socket programming in C like the steps to follow and all. Now I want to create a packet and send it to my server. I thought that I will create a structure</p>
  
  <pre><code>    struct packet  
      { 
      int srcID;
      long int data;
      .....
      .....
      .....
      };
      struct packet * pkt;
  </code></pre>
  
  <p>Before doing send(), I thought that I will write values inside the packet using</p>
  
  <pre><code>   pkt-&gt; srcID = 01
     pkt-&gt; data = 1 2 3 4 
  </code></pre>
  
  <p>I need to know whether I am on the right path, and if yes then can I send using</p>
  
  <pre><code>      send(sockfd, &amp;packet, sizeof(packet), 0)
  </code></pre>
  
  <p>for receiving</p>
  
  <pre><code>    recv(newsockfd, &amp;PACKET, sizeof(PACKET), 0)
  </code></pre>
  
  <p>I have just started with network programming, so I am not sure whether i am on the right path or not. It would be of great help if anyone can guide me with my question in any form (theoretical,examples etc). Thanks in advance.</p>