winsock2

Implicit declaration of function 'getaddrinfo' on MinGW

时光怂恿深爱的人放手 提交于 2020-01-11 03:10:49
问题 I have a C program that uses getaddrinfo() . It works as expected on Linux and Mac OS X. I'm in the middle of porting it to Windows. When I compile it (with MinGW gcc) I get the following warnings: ext/socket/socket.c: In function 'sl_tcp_socket_init': ext/socket/socket.c:98:5: warning implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration] ext/socket/socket.c:104:9: warning implicit declaration of function 'freeaddrinfo' [-Wimplicit-function-declaration] Then the

Getting IP adress associated to REAL hardware ethernet controller in Windows C

非 Y 不嫁゛ 提交于 2020-01-07 09:44:18
问题 I tried to search for it but I could'nt find any working soultions. Nowadays Windows can detect more than ONE PROPER HARDWARE installed eternet controlled due to Hamachi, Virtual box etc etc. Now i need to get the real IP adress of machine. When i tried do it by using gethostbyname it returned IP adress of my Hamachi client. Now I need to find 100% solid method to receive real ip adress. Any links/tips/articles/methods really appreciate. EDIT: So far got this - method sugested by Remy Lebau,

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

WinSock program in C, works only on local computer

房东的猫 提交于 2020-01-03 02:50:13
问题 I'm a newbie in Network Programming, started to learn how to use WinSock in C. I don't have any knowledge in Networking right now. Anyway, I've written the following code for Client and Server, using WinSock. Server: #include <stdio.h> #include <stdlib.h> #include <winsock2.h> #include <ws2tcpip.h> #define MY_ERROR 1 #define PORT 7777 #define MAX_NUM_CLIENTS 1 /* I don't know how to thread right now. */ #define MAX_CLIENT_MSG_LEN 1000 int main() { WSADATA wsa; SOCKET mySocket, acceptSocket;

is winsock2 thread safe?

依然范特西╮ 提交于 2019-12-29 07:48:21
问题 I am writing a small 3 servers and 1 client program. the 2 servers send tcp messages and the last one sends upd datagrams using winsock2. I am wondering if i can make simulanious recvfrom() by using threads (OpenMP or boost::threads) so that 2 threads listen from the same socket on the same port at the same time. I am using VC++ 2010 on windows7. Thank you for your help. 回答1: Yes, sockets are thread-safe, however you have to be careful. One common pattern (when using blocking IO) is to have

Why did my winsocks2 send result in 10057 error sometimes?

北城以北 提交于 2019-12-25 17:12:52
问题 I did tcp socket connection with normal(?) steps as the code shows below. But send sometimes result in 10057 error while server-end printed some log which says connection is in, I have no idea about what's wrong with my code. Any help is appreciated. Any information about stable and robust windows socket programming is appreciated. MSDN description about 10057 error: Socket is not connected.A request to send or receive data was disallowed because the socket is not connected and (when sending

IO Completion ports: separate thread pool to process the dequeued packets?

爷,独闯天下 提交于 2019-12-24 18:41:41
问题 NOTE : I have added the C++ tag to this because a) the code is C++ and b) people using C++ may well have used IO completion ports. So please don't shout. I am playing with IO completion ports, and have eventually fully understood (and tested, to prove) - both with help from RbMm - the meaning of the NumberOfConcurrentThreads parameter within CreateIoCompletionPort() . I have the following small program which creates 10 threads all waiting on the completion port. I tell my completion port to

Obtaining the source IP and port of an INADDR_ANY client socket before the TCP three-way handshake?

好久不见. 提交于 2019-12-23 04:13:55
问题 I'm on Windows 7, using bind before connect with SO_REUSEADDR , and setting the local address structure to IP address INADDR _ANY and port 0 (zero), in order to let the operating system select the source details for a client socket. Firstly, I've read that it's not possible to get the source IP before connecting to the server, since it's being chosen at this point and several addresses can be valid. But the port is selected before the connection, so is there a way to get it? ( getsockname()

Listening to a UDP broadcast

☆樱花仙子☆ 提交于 2019-12-23 03:00:14
问题 I need to listen to a network broadcast coming over UDP. The datagram contains a j4cDAC_broadcast struct. I have tried following a few tutorials, but they seem to have left a few things out and dont have very detailed explanations, if any. With what I have right now I am getting an error BIND FAILED 10049 and error 10049 indicates that the address is unavailable. The broadcast is coming in on 255.255.255.255:7654. How do I fix this error? This is what I have so far: void test() { WSADATA wsd;

Delphi TClientSocket replacement using winsock2 and IOCP?

梦想与她 提交于 2019-12-22 18:46:45
问题 Is there such a thing? It needs to be asynchronous (no Indy). 回答1: Try HPScktSrvr - http://www.torry.net/pages.php?id=220#939383 回答2: These may or may not be what you are looking for, but worth a shot: Ararat Synapse - For Delphi 2009 support you need to get the latest from SVN. /n Software's IP*Works - Commercial, but very full featured. Good luck! 回答3: Check http://voipobjects.com/index.php?page=delphi-iocp-library It is migrated iocpclasses.sourceforge.net (i'm an author). Enjoy :) 来源: