Windows Sockets 2 (Winsock) enables programmers to create advanced Internet, intranet, and other network-capable applications to transmit application data across the wire, independent of the network protocol being used
Questions tagged [winsock2]
964 questions
9
votes
1 answer
IPPROTO_RM blocks during accept call
This question is similar to https://stackoverflow.com/questions/11650328/using-reliable-multicast-pragmatic-general-multicast-not-returning-from-accept, but my code is slightly different from its, so it may result in a different answer.
I am…

Anthony
- 12,177
- 9
- 69
- 105
8
votes
1 answer
gethostbyname says No such service is known. The service cannot be found in the specified name space
This simple piece of code in Windows results in an annoying debug message printed by gethostbyname.
#include
#include
int main()
{
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
hostent* he =…

s4eed
- 7,173
- 9
- 67
- 104
8
votes
1 answer
How can I stop/restart listening and accepting on a server socket in Winsock2 C++?
I made a socket (Winsock2) in Visual Studio Pro C++ to listen on a port for connections (TCP). It works perfectly, but I let it run in its own thread, and I want to be able to shut it down with the hopes of restarting it later. I can terminate the…

Sefu
- 2,404
- 8
- 42
- 59
8
votes
2 answers
missing messages when reading with non-blocking udp
I have problem with missing messages when using nonblocking read in udp between two hosts. The sender is on linux and the reader is on winxp. This example in python shows the problem.
Here are three scripts used to show the problem.
send.py:
import…

lgwest
- 1,347
- 5
- 16
- 26
8
votes
3 answers
Increase the TCP receive window for a specific socket
How to increase the TCP receive window for a specific socket?
- I know how to do so for all the sockets by setting the registry key TcpWindowSize,
but how do do that for a specific one?
According to MSFT's documents, the way is
Calling the…

rkellerm
- 5,362
- 8
- 58
- 95
8
votes
0 answers
Winsock tracing can't get verbose level events
while it's very easy to get info level tracing started with Windows-Winsock-AFD using:
netsh trace start provider=Microsoft-Windows-Winsock-AFD TraceFile=my_
winsock_log3_trace.etl
the file generated seems to not include verbose level events such…

user1730969
- 462
- 3
- 10
7
votes
3 answers
Memory Leak GETIPFROMHOST
I have this code right here to retrive the IP-address from a hostname:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils,
winsock;
function GetIPFromHost(const HostName: string): string;
type
TaPInAddr = array[0..10] of PInAddr;
…

Ben
- 3,380
- 2
- 44
- 98
7
votes
2 answers
Socket recv call freezes thread for approx. 5 seconds
I've a client server architecture implemented in C++ with blocking sockets under Windows 7. Everything is running well up to a certain level of load. If there are a couple of clients (e.g. > 4) receiving or sending megabytes of data, sometimes the…

michael
- 81
- 5
7
votes
1 answer
Why does WSAStringToAddress take a non-const AddressString?
The Windows documentation for WSAStringToAddress states:
INT WSAAPI WSAStringToAddress(
_In_ LPTSTR AddressString,
_In_ INT AddressFamily,
_In_opt_ LPWSAPROTOCOL_INFO lpProtocolInfo,
_Out_ LPSOCKADDR …

jww
- 97,681
- 90
- 411
- 885
7
votes
1 answer
SChannel/SSL implementation?
I can implement HTTP using "win sockets" easily , but I've been struggling to implement HTTPS using "SChannel" which is pretty much poorly documented "at least for me". How can I establish a secure connection for HTTPS communication and is there any…

M.U
- 381
- 3
- 10
7
votes
1 answer
Why does MinGW-w64 require winsock2 to be manually included?
Some code and associated warnings/errors:
#include
#include
int main() { }
F:/Prog/mingw-w64/x86_64-4.9.2-win32-seh-rt_v3-rev1/mingw64/x86_64-w64-mingw32/include/ws2ipdef.h:71:3: error: 'ADDRESS_FAMILY' does not name a…

M.M
- 138,810
- 21
- 208
- 365
6
votes
0 answers
Windows sockets: How to immediately detect TCP RST on nonblocking connect()?
Our software (Nmap port scanner) needs to quickly determine the status of a non-blocking TCP socket connect(). We use select() to monitor a lot of sockets, and Windows is good at notifying us when one succeeds. But if the port is closed and the…

bonsaiviking
- 5,825
- 1
- 20
- 35
6
votes
3 answers
Why am I getting linker errors for ws2_32.dll in my C program?
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?

Sanjay
- 1,555
- 2
- 10
- 6
6
votes
2 answers
Handling asynchronous sockets in WinSock?
I'm using a message window and WSAAsyncSelect. How can I keep track of multiple sockets (the clients) with one message window?

Jason Dietrich
- 155
- 1
- 1
- 8
6
votes
3 answers
boost::asio::io_service crash in win_mutex lock
I've been having a problem with boost::asio where timer and/or sockets created using a global io_service instance crash during construction. The system where the crash occurs is as follows:
Windows 7
Visual Studio 2013 Express for Windows Desktop;…

lukecfg
- 63
- 1
- 5