0

Trying to make a whois tcp lookup that directly queries verisign via port 43. Got it to work in command line + visual studio community 2017.

When I try to use em++ to compile it, I get an error.

C:\Users\Samuel Walker\source\repos\Barebones_Client\Barebones_Client>em++ -O3 --emrun -s WASM=1 -o main.html main.cpp
main.cpp:3:10: fatal error: 'WS2tcpip.h' file not found
#include <WS2tcpip.h>
         ^~~~~~~~~~~~
1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting

I'm using WS2tcpip.h for the script. It's essential, but yeah still entirely new to C++ and following guides and snippets online. Is this a matter of somehow telling enscripten to know where windows header files are or am I completely off?

sfxworks
  • 1,031
  • 8
  • 27

1 Answers1

3

You cannot. WS2tcpip.h is part of the Windows API, which is not available in the browser.

You can make HTTP requests from JavaScript, but there are no generic sockets to be able to make requests using the WHOIS protocol. You will need to contact a web server that offers an API for making WHOIS requests. Also see this question and its answers: Whois with JavaScript

rdb
  • 1,488
  • 1
  • 14
  • 24
  • This does answer my question. However, I am still left with a lack of knowledge on what to do now as I am trying to challenge myself by avoiding bringing a backend into this. I know websockets have been a thing, but whois queries require TCP sockets. Is there a library I can use that will assist me here? – sfxworks Sep 17 '18 at 02:04
  • 1
    @quantomworks I have added some more info to the answer. I think the only way is to contact some API or service. There appear to be some WHOIS API services out there, or you could host your own server with an entry point that can be called via an AJAX request. – rdb Sep 17 '18 at 10:33