Common C code in both Linux and Windows RRS feed

  • Question

  • Dear All,

    I have a Socket programming which has written in 'C ' running in Linux. I am planning to port the same code in Windows environment.  Seems it is not easy compilation process in windows using the same code which running in linux. Following are the header files giving an exceptions. 

    #include <arpa/inet.h>
    #include <sys/types.h>
    #include <netinet/in.h>
    #include <resolv.h>

    How to overcome this issues? , using the same C code in linux and windows ?

    Thanks and Regards,

    Thanks in Advance Suresh M
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"

    Wednesday, October 26, 2016 7:49 AM

All replies

  • Apologies for the late response but I stumbled on this issue myself and have a partial solution for those who ask this in the future;

    The linux inclusions

    #include <arpa/inet.h>
    #include <netinet/in.h>
    #include <netdb.h>

    can be replaced with the following windows inclusion:

    #include <winsock.h> 

    Thursday, June 7, 2018 10:09 PM