wsastartup

Winsock error code 10014

爱⌒轻易说出口 提交于 2020-01-01 12:07:50
问题 string SendRequestToServer(std::string url) { struct sockaddr_in addr = { 0 }; struct hostent *host = NULL; // If the URL begins with http://, remove it. if(url.find("http://") == 0) url.erase(0, 7); // Get the host name. string hst = url.substr(0, url.find('/', 0)); url.erase(0, url.find("/", 0)); // Connect to the host. host = gethostbyname(hst.c_str()); if(!host) { Print("%s", "Could not resolve the hostname."); int error = WSAGetLastError(); return "failed"; } } It seems I'm returning

Is it possible to tell if WSAStartup has been called in a process?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 11:08:43
问题 I've started writing an ActiveX control that makes use of sockets. Applications that use this control may or may not also use sockets. Is it possible for my control to tell whether WSAStartup has been called? If not, call it. A little test reveals that calling WSAStartup multiple times is tollerated. But what happens if a different winsock version is requested? will this break other parts of the application? 回答1: Yes it is possible. And here is how it's done. bool WinsockInitialized() {

Is the .NET use of WSAStartup safe for 64-bit apps?

被刻印的时光 ゝ 提交于 2019-12-10 15:25:22
问题 There is a mismatch between the .NET Framework version and the native Win32 version of the WSAData struct, for 64-bit apps, because the order of the fields is different. I had copied the .NET version for use in our C#-based product and a coworker is concerned that I have caused a memory corruption. Is there any risk of memory corruption because of this mismatch when using DllImport / PInvoke? Is there any risk of an invalid memory access when marshaling the native version to the managed

Winsock error code 10014

久未见 提交于 2019-12-04 08:21:54
string SendRequestToServer(std::string url) { struct sockaddr_in addr = { 0 }; struct hostent *host = NULL; // If the URL begins with http://, remove it. if(url.find("http://") == 0) url.erase(0, 7); // Get the host name. string hst = url.substr(0, url.find('/', 0)); url.erase(0, url.find("/", 0)); // Connect to the host. host = gethostbyname(hst.c_str()); if(!host) { Print("%s", "Could not resolve the hostname."); int error = WSAGetLastError(); return "failed"; } } It seems I'm returning "failed" quite frequently. Here are the values of various variables when my breakpoint at "return failed"

How does WSAStartup function initiates use of the Winsock DLL?

梦想与她 提交于 2019-12-03 07:15:50
问题 How does WSAStartup function initiates use of the Winsock DLL? According to the documentation The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the version of Windows Sockets required and retrieve details of the specific Windows Sockets implementation. The application or DLL can only issue further Windows Sockets functions after successfully calling WSAStartup. This function initializes WSADATA data

How does WSAStartup function initiates use of the Winsock DLL?

走远了吗. 提交于 2019-12-02 20:47:40
How does WSAStartup function initiates use of the Winsock DLL? According to the documentation The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the version of Windows Sockets required and retrieve details of the specific Windows Sockets implementation. The application or DLL can only issue further Windows Sockets functions after successfully calling WSAStartup. This function initializes WSADATA data structure, but in socket programming we don't pass WSDATA to any function so how does the program comes

WSAStartup link error

a 夏天 提交于 2019-12-02 06:32:40
问题 I am using EVC++ and I want to compile the program which uses the sockets. I've included #include <winsock2.h> And I have included in project properties a path to Ws2.lib But still get the error at link step: error LNK2019: unresolved external symbol WSAStartup referenced in function ... How to resolve this problem? 回答1: #pragma comment(lib,"WS2_32") after all #include 's 回答2: You haven't linked your program with the winsock library. The Winsock 2 library is called ws2_32.lib (static) or ws2

WSAStartup link error

限于喜欢 提交于 2019-12-02 00:46:10
I am using EVC++ and I want to compile the program which uses the sockets. I've included #include <winsock2.h> And I have included in project properties a path to Ws2.lib But still get the error at link step: error LNK2019: unresolved external symbol WSAStartup referenced in function ... How to resolve this problem? #pragma comment(lib,"WS2_32") after all #include 's You haven't linked your program with the winsock library. The Winsock 2 library is called ws2_32.lib (static) or ws2_32.dll (dynamic). It should already be on your system; you just need to tell your compiler/linker to link your

Why does Windows not allow WinSock to be started while impersonating another user

南楼画角 提交于 2019-12-01 02:39:52
问题 Using my own program or others I can't get winsock to run when calling if the process is created with CreateProcessWithLogonW or CreateProcessAsUserW. It returns this error when I create the socket: WSAEPROVIDERFAILEDINIT 10106 Service provider failed to initialize. The requested service provider could not be loaded or initialized. This error is returned if either a service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or NSPStartup function failed .

MinGW + Boost: undefined reference to `WSAStartup@8'

血红的双手。 提交于 2019-11-30 09:13:00
问题 below is what I execute D:\Just4Fun\software\>make -f Makefile.hands stest g++.exe -g -D_WIN32_WINNT=0x0601 -ID:\Boost\boost_1_51_0 -LD:\Boost\boost_1_51_0\stage\lib -LD:\MinGW\lib -lboost_system-mgw46-d-1_51 -lboost_filesystem-mgw46-d-1_51 -lboost_iostreams-mgw46-d-1_51 -lws2_32 -lwsock32 -o TestSerial.exe TestSerial.cpp below is the result of that C:\Users\oleg\AppData\Local\Temp\ccXpC7RG.o: In function 'ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh': D:/Boost/boost_1_51_0