winsock2

Problem using Connect(), send(), recv, with UDP sockets

半腔热情 提交于 2019-12-01 04:17:40
问题 For my Uni assignment I have to create a fast action paced networked game and so have chosen to use UDP as opposed to TCP. I am aware of a lot of the differences in programming both UDP and TCP and have read through most of the relevant parts of MSDN's documentation on winsock. On MSDN it states that creating a UDP socket via the connect() function should bind the socket to the address and port specified and as a result be able use the send() and recv() functions with the created socket. For

Implicit declaration of function 'getaddrinfo' on MinGW

為{幸葍}努か 提交于 2019-11-30 21:18:26
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 entire thing fails to link with undefined references to getaddrinfo() and freeaddrinfo() . Now, according

Boost::asio winsock and winsock 2 compatibility issue

三世轮回 提交于 2019-11-30 12:50:31
问题 My project uses windows.h in which winsock.h is used, and I need to include boost:assio which uses winsock2. So I get many errors that says Winsock.h already included. I can define WIN32_LEAN_AND_MEAN. so that windows.h wouldn't use winsock. The problem is , that I need windows.h to use it, and I just need Asio for asynchronous timers. I don't need its winsock2.h . I tried searching how to disable its winsock2 use, and I found that I could do that by defining BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN

Why am I getting linker errors for ws2_32.dll in my C program?

余生长醉 提交于 2019-11-30 09:45:19
I am writing my program in Visual Studio 2010. I am unable to link a file named ws2_32.dll with my project. Can anyone tell me how I can do that? Typically you dont link to ws2_32.dll directly but to WS2_32.Lib, which you can find in the Windows SDK. So in your code you write #include <winsock2.h> and to your linker-settings you add WS2_32.Lib and you're good to go. The Windows SDK is here: http://msdn.microsoft.com/en-us/windows/bb980924.aspx The first order of business is importing the header file that defines functions exported by ws2_32.dll . You do that by adding the following statement

Winsock2 - How to use IOCP on client side

孤街浪徒 提交于 2019-11-30 07:52:51
I’ve recently started learning IOCP on Windows and been reading the following article: http://www.codeproject.com/Tips/95363/Another-TCP-echo-server-using-IOCP You can download the sample for the article from: http://dl.dropbox.com/u/281215/documentation/iocp-1.00.html The sample contains two simple applications – iocp_echo_server and TcpEchoClient . I understand that IOCP is usually used on the server side of the client/server model but I’d like to create a client using IOCP. I’ve so far tried modifying the client sample above so that whenever the server sends a response to the client, it

Boost::asio winsock and winsock 2 compatibility issue

谁说我不能喝 提交于 2019-11-30 03:53:10
My project uses windows.h in which winsock.h is used, and I need to include boost:assio which uses winsock2. So I get many errors that says Winsock.h already included. I can define WIN32_LEAN_AND_MEAN. so that windows.h wouldn't use winsock. The problem is , that I need windows.h to use it, and I just need Asio for asynchronous timers. I don't need its winsock2.h . I tried searching how to disable its winsock2 use, and I found that I could do that by defining BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN before including boost:asio, but I still get the same error. #include <windows.h> #define BOOST_ASIO

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

谁说胖子不能爱 提交于 2019-11-30 01:58:41
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? Yes it is possible. And here is how it's done. bool WinsockInitialized() { SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == INVALID_SOCKET && WSAGetLastError() ==

Can't include Winsock2.h in MSVC 2010

自古美人都是妖i 提交于 2019-11-29 19:57:41
问题 I cannot include WinSock2.h in a msvc++2010 project. At first I though it was something I was doing wrong, so I created an empty project to test my sanity. The empty project is as follows #include <Windows.h> #include <WinSock2.h> int main(void){ system("echo Hello World"); system("pause"); return 0; }; It compiles and works fine without the line #include <WinSock2.h> but it fails with a long list of errors when I do try and include WinSock2.h. Errors: 1> Main.cpp 1>c:\program files\microsoft

Winsock2's select() on fd 0 (stdin) fails

*爱你&永不变心* 提交于 2019-11-29 18:17:22
Using Winsock2 the code sequence below returns -1 (failure) for select() . #include <Winsock2.h> #include <stdio.h> ... int rc; int fdstdin = fileno(stdin); /* returns 0 as expected */ fd_set fds; FD_ZERO(&fds); FD_SET(fdstdin, &fds); rc = select(1, &fds, NULL, NULL, NULL); ... Is this the expected behaviour when using Winsock2 or am I missing something? This is expected behavior. As mentioned all over the documentation , winsock's select function only works on sockets, and stdin is not a socket. If you had called WSAGetLastError , you undoubtedly would have found that the cause was

Why am I getting linker errors for ws2_32.dll in my C program?

时光毁灭记忆、已成空白 提交于 2019-11-29 14:40:52
问题 I am writing my program in Visual Studio 2010. I am unable to link a file named ws2_32.dll with my project. Can anyone tell me how I can do that? 回答1: Typically you dont link to ws2_32.dll directly but to WS2_32.Lib, which you can find in the Windows SDK. So in your code you write #include <winsock2.h> and to your linker-settings you add WS2_32.Lib and you're good to go. The Windows SDK is here: http://msdn.microsoft.com/en-us/windows/bb980924.aspx 回答2: The first order of business is