winsock

How to get internal IP, external IP and default gateway for UPnP

让人想犯罪 __ 提交于 2020-01-03 05:19:07
问题 I'm wondering how I'd go about getting the: Internal IP address; External IP address; and Default gateway in Windows (WinSock) and Unix systems. Thanks in advance, 回答1: There is no general purpose mechanism that works on Windows and UNIX. Under Windows you want to start with GetIfTable(). Under most UNIX systems, try getifaddrs(). Those will give you various things like the IP address of each interface. I'm not sure how one would go about getting the default gateway. I would guess that it is

Win Socket Creation fails with Error code 10022 if non super user

让人想犯罪 __ 提交于 2020-01-03 04:15:49
问题 I encountered a very peculiar behavior on windows 7 with winsockets. Two librarys (Wt http://www.webtoolkit.eu/ libwebsocket https://libwebsockets.org/ ) and as well myself with a sample code got the errorcode 10022 ( Invalid argument. ) when running as normal user, and never when running as superuser. Neither the devs at the lib projects nor I can find a reason. I fear that its maybe a very hidden idiotic group rule in our company. Example code to trigger: #include <cstdlib> #ifndef WIN32

connecting to an IP address instead of localhost?

风格不统一 提交于 2020-01-03 03:29:30
问题 this is my second go at this, I've written a server application as below which outputs whatever the client sends. I have one server.exe version where it listens to anything using INADDR_ANY , Having done that I can use my client and connect to the server if I specify the client connect to localhost (Which all works fine). but if I use my own IP address instead of localhost for the client, I cannot connect to the server?. Shouldn't I be able to connect to the server this way?. I used another

dnf小小外挂外挂原理及使用

≯℡__Kan透↙ 提交于 2020-01-03 03:26:37
dnf小小外挂几乎所有的中都使用了鼠标来改变角色的位置和方向,玩家仅用一个小小的鼠 标,就可以使角色畅游天下。 那么,我们如何实现在没有玩家的参与下角色也可以自动行走呢。其实实现这个并不 难,仅仅几个Windows API函数就 可以搞定dnf小小外挂,让我们先来认识认识这些API函数。   (1) 模拟鼠标动作API函数mouse_event,它可以实现模拟鼠标按下和放开等动作。     VOID mouse_event(       DWORD dwFlags, // 鼠标动作标识。       DWORD dx, // 鼠标水平方向位置。       DWORD dy, // 鼠标垂直方向位置。       DWORD dwData, // 鼠标轮子转动的数量。       DWORD dwExtraInfo // 一个关联鼠标动作辅加信息。     );   其中,dwFlags表示了各种各样的鼠标动作和点击活动,它的常用取值如下:    MOUSEEVENTF_MOVE 表示模拟鼠标移动事件。    MOUSEEVENTF_LEFTDOWN 表示模拟按下鼠标左键。    MOUSEEVENTF_LEFTUP 表示模拟放开鼠标左键。    MOUSEEVENTF_RIGHTDOWN 表示模拟按下鼠标右键。    MOUSEEVENTF_RIGHTUP 表示模拟放开鼠标右键。

talking between python tcp server and a c++ client

匆匆过客 提交于 2020-01-02 09:09:31
问题 I am having an issue trying to communicate between a python TCP server and a c++ TCP client. After the first call, which works fine, the subsequent calls cause issues. As far as WinSock is concerned, the send() function worked properly, it returns the proper length and WSAGetLastError() does not return anything of significance. However, when watching the packets using wireshark, i notice that the first call sends two packets, a PSH,ACK with all of the data in it, and an ACK right after, but

WebMatrix无法启动问题

一个人想着一个人 提交于 2020-01-02 03:02:45
之前已经听闻过WebMatrix这个工具,今天正好有时间,遂想尝试一下,看看与Visual Studio有什么区别。 首先是从其官网上下载安装包,地址在 这里 。文件很小,只有94K。 接着双击文件进行安装,无需任何选择,过程十分简单。当然,这么小的安装包肯定无法满足安装需要,所以必要的文件还要另外通过网络下载。依据网速的快慢,安装的时间会有所变化。 完成安装之后便可以启动程序了。为了尽早体验WebMatrix建站的感觉,所以一开始选择了模板方式快捷建立网站。 数秒钟后,一个崭新的“入门网站”便诞生了。果然方便! 看了一下界面,菜单上有“启动”按钮,就先先看看网站的效果吧。点击,跳出了“以下网站已停止:“入门网站”。”的警告。 这是怎么回事? 第一反应是IIS出问题了。于是在CMD中运行“C:\Program Files (x86)\IIS Express>iisexpress.exe /trace:error”命令。结果出现了下面这样的错误: 正在启动 IIS Express… Initializing the W3 Server Started CTC = 4485278 W3 Server initializing WinSock. CTC = 4485293 W3 Server WinSock initialized. CTC = 4485293 W3 Server

Why does TCP/IP on Windows7 take 500 sends to warm-up? ( w10,w8 proved not to suffer )

情到浓时终转凉″ 提交于 2020-01-02 02:19:07
问题 We are seeing a bizarre and unexplained phenomenon with ZeroMQ on Windows 7 , sending messages over TCP. ( Or over inproc , as ZeroMQ uses TCP internally for signalling, on Windows ). The phenomenon is that the first 500 messages arrive slower and slower, with latency rising steadily. Then latency drops and messages arrive consistently rapidly, except for spikes caused by CPU/network contention. The issue is described here: https://github.com/zeromq/libzmq/issues/1608 It is consistently 500

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

send() not deliver all bytes?

♀尐吖头ヾ 提交于 2019-12-30 10:42:41
问题 Why doesn't send() in winsock guarantee delivery of the all bytes you request? This is TCP and it's blocking sockets. Similarly, this happens when non-blocking. How can you guarantee that you send everything? I've noticed recv() does the same. 回答1: If it didn't send everything, just call send again on the rest. If blocking, you can do it immediately. If non-blocking, you can either wait or use a socket discovery method (like select or I/O completion ports). The same goes for recv . If you

Getting PID of peer socket on Windows

天涯浪子 提交于 2019-12-29 09:17:15
问题 I am writing a web proxy and when a request comes in (typically from the browser on the machine), I'd like to also get the pid and any other requesting application. Is there any way to determine this using Win32? 回答1: What you are asking for is only possible if the client and server are running on the same machine. When a client is connected to the proxy, the proxy can use getpeername() to query the socket for the remote client IP/Port (or use the IP/Port reported by accept() ) and