How to I tell em++ to find WS2tcpip.h - c++

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?

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

Related

How to use SSL_CTX_set_split_send_fragment

How can I use SSL_CTX_set_split_send_fragment?
I include and use ssl and crypto linker in my project but when I build my C++ project I face with this error:
error: ‘SSL_CTX_set_split_send_fragment’ was not declared in this scope
My OpenSSL version is 1.0.1e-fips 11 Feb 2013 and gcc version 4.8.5 20150623.
error: ‘SSL_CTX_set_split_send_fragment’ was not declared in this scope
My OpenSSL version is 1.0.1e-fips 11 Feb 2013 and gcc version 4.8.5 20150623.
If you visit OpenSSL's online man pages at OpenSSL Manpages and navigate into the 1.0.1 branch, and then into The SSL library, you will see its not part of OpenSSL 1.0.1. Its not part of OpenSSL 1.0.2, either.
You should try OpenSSL 1.1.0. That will get you past the compile error. Also see the SSL_CTX_set_split_send_fragment man page :).
Also note that some APIs are missing man pages, so the man pages are not a definitive test for availability. A case where an public API is available but undocumented used to be PKCS12_newpass, if I recall correctly. Its also possible a man page is missing because OpenSSL considers the API private. However, in the case of SSL_CTX_set_split_send_fragment, the API is not present:
$ cd openssl-1.0.2h
$ grep -IR SSL_CTX_set_split_send_fragment *
$
I don't usually see questions about the underlying transport PDU size, the record layer size or fragmentation size. In fact, most of the mobile platforms I work on ignore the TCP SO_* options related to them. Carriers effectively hard code their values and that's it. There's no sense in trying to work around it or improve upon it.
With that said, you can usually find good tuning and performance discussions when researching "time to first byte". One I am familiar with is Optimizing NGINX TLS Time To First Byte (TTTFB). It starts by increasing the write buffer size:
(void) BIO_set_write_buffer_size(wbio, 16384);
But I'm not sure how useful BIO_set_write_buffer_size (or anything else) will be given you don't have access to the clients or the MS SQL server.

WS-Discovery & gSOAP set up in VS2013

My overarching goal is to create a small ONVIF client for getting camera information in either C or C++.
gSOAP seemed like a good candidate and first thing I wanted to achieve was to make a small console application which would list the addresses of a bunch of cameras I have on my network using WS-Discovery, something I've done before with a little .NET application.
The problem is I'm stumbling at the first hurdle and I'm a touch confused as to what I'm supposed to be doing. I started out by doing the following:
wsdl2h.exe -o WSDiscovery.h WS-Discovery.wsdl http://www.w3.org/2006/03/addressing/ws-addr.xsd
soapcpp2.exe -i -C -Iimport WSDiscovery.h -d output
,
I then made a project from the resulting soapC.cpp stdsoap2.cpp soapH.h soapStub.h. Adding in threads.h wsaapi.h wsddapi.h threads.c wsaapi.c wsddapi.c from gsoap
This doesn't compile however giving:
wsaapi.h(134): error C2061: syntax error : identifier 'wsa__FaultSubcodeValues'
I think I'm going very wrong here and I'm confused about exactly what a 'plugin' is in the context of gSOAP (my experience with external libraries like this is extremely limited and I have no real formal training in CS). Am I just supposed to be doing what I'm doing now with the wsdd files or are they supposed to be used as part of the soapcpp2.exe process? Am I actually supposed to be using wsdl2h.exe if I just want WS-Discovery?
I can't really make sense of the documentation and don't understand how I'm supposed to get this working. Some help would be greatly appreciated so I can crack on with the actual hard part!
I guess the problem is coming from usage of WS-Adressing plugins (wsaapi.h/.c) with http://www.w3.org/2006/03/addressing/ws-addr.xsd schema.
gSOAP contains the wsdl2h generated file that could be used by WS-discovery plugins (wsddapi.h/.c).
[GSOAP_DIR]/import/wsdd10.h for WS-Discovery 1.0 2005 that use WS-Adressing 2004/08
[GSOAP_DIR]/import/wsdd.h for WS-Discovery 1.1 2009 that use WS-Adressing 2005/08
As ONVIF use WS-Discovery 1.0 you could generate discovery implementation using :
soapcpp2 -Cx [GSOAP_DIR]/import/wsdd10.h -I [GSOAP_DIR]/import -d output
Next you should be able to build your project including wsddapi.c wsaapi.c soapClient.cpp soapC.cpp
You can find some of my experiments from github ws-discovery

How to run gSOAP code generator without internet connection?

I am trying to generate code using wsdl2h/soap2cpp for the onvif media WSDL http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl. This wsdl have some dependencies.
Reading the gSOAP FAQ http://www.cs.fsu.edu/~engelen/soapfaq.html, I finally extract the needed namespaces in following typemap.dat
trt = "http://www.onvif.org/ver10/media/wsdl"
tt = "http://www.onvif.org/ver10/schema"
wsnt = "http://docs.oasis-open.org/wsn/b-2"
wsrfbf = "http://docs.oasis-open.org/wsrf/bf-2"
wstop = "http://docs.oasis-open.org/wsn/t-1"
xop="http://www.w3.org/2004/08/xop/include"
wsa5 = <http://www.w3.org/2005/08/addressing>
With this mapping the gSOAP code generator run correctly :
wsdl2h media.wsdl
soapcpp2 -2ix media.h -I /usr/share/gsoap/import
But this need to have an internet connection. I would like to build with files that are stored locally.
In the wsdl2h help there is an option that looks interesting :
-i don't import (advanced option)
So I download what was downloaded by wsdl2h :
http://www.onvif.org/onvif/ver10/schema/onvif.xsd
http://docs.oasis-open.org/wsn/b-2.xsd
http://www.w3.org/2004/08/xop/include
http://docs.oasis-open.org/wsrf/bf-2.xsd
http://docs.oasis-open.org/wsn/t-1.xsd
And next run
wsdl2h -im media.wsdl onvif.xsd b-2.xsd include bf-2.xsd t-1.xsd
soapcpp2 -2ix media.h -I /usr/share/gsoap/import
But this fails with this kind of output :
** The gSOAP code generator for C and C++, soapcpp2 release 2.8.7
** Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool is released under one of the following two licenses:
** GPL or the commercial license by Genivia Inc.
media.h(164): syntax error
media.h(163): Syntax error: declaration expected
media.h(173): syntax error
...
In media.h the code reference strucure coming from ws-addressing. Next I tried different things importing more xsd but I did not find a way to resolve the missing dependencies.
Perhaps this is not the proper way to build from local file. Anyway I would like to avoid any modification in the wsdls and xsd files. An alternative could be a catalog to map the remote url to local url (like Apache CXF) but I did not find anything like this in gSOAP documentation.
Thanks for sharing your experiences.
I found only partial documentation of the typemap.dat format from gSOAP site http://www.cs.fsu.edu/~engelen/soapdoc2.html. However I noticed that some namespace definition use <url> instead of "url".
After some tries, this give a solution to the problem, defining namespace enclosed inside <>.
So I modified the typemap.dat like this :
trt=<http://www.onvif.org/ver10/media/wsdl>
tt=<http://www.onvif.org/ver10/schema>
wsnt=<http://docs.oasis-open.org/wsn/b-2>
wsrfbf=<http://docs.oasis-open.org/wsrf/bf-2>
wstop=<http://docs.oasis-open.org/wsn/t-1>
xop=<http://www.w3.org/2004/08/xop/include>
wsa5=<http://www.w3.org/2005/08/addressing>
Then it is possible to generate code from the media.wsdl without connecting to internet :
wsdl2h media.wsdl onvif.xsd b-2.xsd include bf-2.xsd t-1.xsd
soapcpp2 -2ix media.h -I /usr/share/gsoap/import

why am i seeing this libzdb configure error?

I am attempting to install libzdb on my macbook however I see the following error message when running the configure:
configure:13334: error: setjmp is required
the setjmp.h file resides within /usr/include and is specified within my "$PATH" as
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/include
Can someone please advise as to how i can rectify this issue?
thanks in advance
I've stumbled across this error while building one of my own programs when I wanted to use setjmp() and longjmp(). For some reason, the toolchain that resides in / on OS X is flawed, and the <setjmp.h> header file is missing the declarations and data types.
To fix it, I had to download Xcode (damn!) and tell the compiler to look for the headers in the freshly installed MacOSX10.7.sdk (or 8) folder:
clang -Wall -o foo foo.c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
ok finally figured it out. For those who have seen messages like this be warned that the configure logs can be misleading. It turned out the binary built fine, however it was failing during runtime because a few mysql libraries could not be found. using the following command *export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/* would fix the problem

Issues compiling vmware web api client code into useable objects

I'm using vmware's web application api in an attempt just to simply retrieve the fields in the "ServiceContent" object. There is an example of how this should be accomplished located at the vmware forum. The example contained there compiles fine for me however I get segfaults when running the simple example - specifically the trace goes back to the soap_serializeheader() function (I believe these are defined in stdsoap2.cpp). My problem is that I do not know how to avoid this segfault and have no idea why this is occurring (as I am following the example almost word for word). I am using OS X tool chain (gcc version 4.0.1 (Apple Inc. build 5465) ) combined with (gsoap release 2.7.16). I tried gsoap 2.8 but got the same result. Below is the procedure I used to get to where I am now.
These are the commands I used to parse the wsdl:
wsdl2h -o vim25.h vimService.wsdl
Once this is parsed, I compiled using the following command:
soapcpp2 -x -C -pvsp vim25.h -I/place/where/stlvector.h/is
this generates files vspC.cpp, vspClient.cpp, and vspVimBindingProxy.cpp. Internally these files have the same prefixes for functions (i.e. ns1/ns2 etc) so my calls are the same as those in the example.
This is the command I am using to compile vspC.cpp and vspClient.cpp:
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspC.cpp
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspClient.cpp
This is the command I use to compile stdsoap2.cpp (if I do not compile with -DWITH_NONAMESPACES I get an error about an undefined symbol "_namepspaces" when I link everything):
g++ -DWITH_COOKIES -DWITH_OPENSSL -DWITH_NONAMESPACES -c stdsoap2.cpp
I then link everything together with the test code (again this is copied almost identically from the example, just with the changes to correctly refer to the files I created):
g++ -DWITH_COOKIES -DWITH_OPENSSL vspC.o vcpClient.o stdsoap2.o testcase.cpp -lssl -lcrypto -o doesntwork
This compiles correctly, but of course fails to run. I read about an OS X user in this vmware forum post who was also having trouble. It appears the gsoap guide says you cannot use stdsoap2.cpp's header and fault serialization codes, and you must compile them separately. The user in the OS X post seems to have done this, however I am not sure how to incorporate them into my test file (he creates the empty env.h file and then compiles it with soap2cpp) - if I include the envH.h file i get about naming conflicts with vspH.h. So a second question would be how do I use soap2cpp to compile all the stubs correctly so that there are not namespace conflicts (which is what I appear to be encountering).
I will not provide the source, as it is displayed at the first vwmare forum link by user stumpr. I do not believe the issue is in the source, but in the way I have used either wsdl2h, soap2cpp, or some incorrect combination of flags during compilation with g++.
Thanks for taking a look, and hopefully some one can resolve the issue!
EDIT I think I may have solved this - by using a 64bit system (and one with more memory). I tried compiling with -m32 on the X.6 and it was not able to do it (complaining about memory issues).
Hopefully someone will stumble upon this and be happy to know the answer.