22

Question is really simple. I need a tool to convert char* to ip adress and use it in

sockaddr_in.s_addr

arpa/inet.h has inet_addr() function, but I am not sure if I already have this file somewhere in MS VS 2010 installation or should I get it elsewhere.

alk
  • 69,737
  • 10
  • 105
  • 255
Pavel Oganesyan
  • 6,774
  • 4
  • 46
  • 84
  • 4
    Check with Al Gore, as he invented the internet. – Bogatyr Dec 12 '13 at 12:45
  • @Bogatyr Really? I got one of copies from http://harmattan-dev.nokia.com/docs/library/html/manpages/headers/arpa/inet.html and some dummy files from redistributable files in apps on my PC and this description also - http://pubs.opengroup.org/onlinepubs/009695399/functions/inet_addr.html Correct answer is to avoid using it on Windows, do I need Al Gore for this? – Pavel Oganesyan Dec 12 '13 at 14:11
  • 5
    Yeah, you'd probably be using some AlGorithms and guess who invented them? – holgac Jan 21 '15 at 19:32

2 Answers2

22

Win32 provides its own implementation of the sockets API (Winsock) which uses slightly different headers.

From the MSDN for inet_addr:

Header Winsock2.h

ComicSansMS
  • 51,484
  • 14
  • 155
  • 166
15

arpa/inet.h is the include used on Unix-like systems.

On Windows, you must use winsock2.h.

Example from the MSDN.

Louis Brunner
  • 263
  • 1
  • 11