title: TCP Socket Client - Redefinition Errors
body: <p>So I'm making a TCP socket client in C (the TCP server in java is already up and running), but I have a few errors.
  Firstly here is some of my code:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdlib.h&gt; //for exit
  #include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;arpa/inet.h&gt;  //for sockaddr_in and inet_addr() #include netinet/in.h
  #include &lt;W5500/w5500.h&gt;
  #include "mnWizSpi.h"   //PacketMaker() and BSB()
  #include &lt;linux/in.h&gt; //for socket(), inet_addr(), send(), ect.
  
  int main(void) {
      struct sockaddr_in servAddr; //Server address
      int prtno = 1234;
  
      //int prtno = atoi(argv[2]);
      if ((sock = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) { //AF_INET = TCP, AF_LOCAL = local to host
          perror("Could not open socket.");
          exit(1);
      }
  
      servAddr.sin_family = AF_INET;                  //Internet Address Family (2 for TCP)
      servAddr.sin_port = htons(prtno);               //Server Port
  
      if(connect(sock, (struct sockaddr*)&amp;servAddr, sizeof(servAddr)) &lt; 0) {
          perror ("Failed Connection");
          exit(1);
      }
  
      //when connected to the java server, the java server will ask for a handshake
      bzero(buffer, 256);
      int n = recv(sock, buffer, 255 , 0);
      if(n &lt; 0)
      {
          perror("Failed to read message");
          exit(1);
      }
  
      //write message to server
      int n = send(sock, msg, strlen(msg), 0);
      if(n &lt; 0)
      {
          perror("Failed to write message");
          exit(1);
      }
      return 0;
  }
  </code></pre>
  
  <p>The errors I get are redefinition errors, coming from linux/in.h</p>
  
  <pre><code>redefinition of 'struct group_filter'
  redefinition of 'struct group_req'
  redefinition of 'struct group_source_req'
  redefinition of 'struct in_addr'
  </code></pre>
  
  <p>ect. Those along with 34 redefined errors. These dissappear when I comment #include , but when I do that I get some undefined reference errors.</p>
  
  <pre><code>undefined reference to 'connect'
  undefined reference to 'htons'
  undefined reference to 'recv'
  undefined reference to 'send'
  undefined reference to 'socket'
  </code></pre>
  
  <p>I have tried other headers that have such functions, but they would end up with the same errors.</p>
  
  <p>I did check the header files on include guards </p>
  
  <pre><code>#ifndef _LINUX_IN_H 
  #define _LINUX_IN_H 
  
  /* header content */
  
  #endif /* _LINUX_IN_H */
  </code></pre>
  
  <p>and they all seem to be fine.</p>
  
  <p>What am I doing wrong / how can I fix this?</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT:
  I work in a ubuntu VM</p>