Questions tagged [winsock]

In computing, the Windows Sockets API (WSA), which was later shortened to Winsock, is a technical specification that defines how Windows network software should access network services, especially TCP/IP.

It defines a standard interface between a Windows TCP/IP client application (such as an FTP client or a web browser) and the underlying TCP/IP protocol stack. The nomenclature is based on the Berkeley sockets API model used in BSD for communications between programs. Initially, all the participating developers resisted the shortening of the name to Winsock for a long time, since there was much confusion among users between the API and the DLL library file (winsock.dll) which only exposed the common WSA interfaces to applications above it. Users would commonly believe that only making sure the DLL file was present on a system would provide full TCP/IP protocol support.

The Windows Sockets API specification defines two interfaces: the API used by application developers, and the SPI, which provides a means for network software developers to add new protocol modules to the system. Each interface represents a contract. The API guarantees that a conforming application will function correctly with a conformant protocol implementation from any network software vendor. The SPI contract guarantees that a conforming protocol module may be added to Windows and will thereby be usable by an API-conformant application. Although these contracts were important when Windows Sockets was first released, as network environments required multi-protocol support (see above) they are now of only academic interest. Included in the Windows Sockets API version 2.0 are functions to use IPX/SPX, but no commercial application is known to exist which utilises this transport, since the protocol was all but obsolete already at the time WSA 2.0 shipped. Microsoft has shipped the TCP/IP protocol stack with all recent versions of Windows, and there are no significant independent alternatives. Nor has there been significant interest in implementing protocols other than the TCP/IP family (includes UDP and RTSP), IrDA, and Bluetooth.

http://en.wikipedia.org/wiki/Winsock

2297 questions
70
votes
5 answers

How to support both IPv4 and IPv6 connections

I'm currently working on a UDP socket application and I need to build in support so that IPV4 and IPV6 connections can send packets to a server. I was hoping that someone could help me out and point me in the right direction; the majority of the…
Charles
  • 2,615
  • 3
  • 29
  • 35
59
votes
4 answers

MinGW linker error: winsock

I am using MinGW compiler on Windows to compile my C++ application with sockets. My command for linking looks like: g++.exe -Wall -Wno-long-long -pedantic -lwsock32 -o dist/Windows/piskvorky { there are a lot of object files } and I have also tried…
Gaim
  • 6,734
  • 4
  • 38
  • 58
50
votes
2 answers

Why should I use non-blocking or blocking sockets?

At first, I must ask that which is the best in which states ? For example a real-time MMORPG server. What if i create a thread per client instead of using non-blocking sockets ? Or What if i use one thread that contains all non-blocking sockets ?…
deniz
  • 2,427
  • 4
  • 27
  • 38
38
votes
5 answers

Do I have to bind a UDP socket in my client program to receive data? (I always get WSAEINVAL)

I am creating a UDP socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP) via Winsock and trying to recvfrom on this socket, but it always returns -1 and I get WSAEINVAL (10022). Why? When I bind() the port, that does not happen, but I have read that it is very…
Juarrow
  • 2,232
  • 5
  • 42
  • 61
35
votes
1 answer

What exactly do socket's Shutdown, Disconnect, Close and Dispose do?

It's surprisingly hard to find a simple explanation on what these four methods actually do, aimed at network programming newbies. People usually just state what they believe is the proper way to close a socket in a particular scenario, but not what…
relatively_random
  • 4,505
  • 1
  • 26
  • 48
33
votes
3 answers

How do I retrieve an error string from WSAGetLastError()?

I'm porting some sockets code from Linux to Windows. In Linux, I could use strerror() to convert an errno code into a human-readable string. MSDN documentation shows equivalent strings for each error code returned from WSAGetLastError(), but I don't…
Drew Hall
  • 28,429
  • 12
  • 61
  • 81
32
votes
5 answers

Is sending data via UDP sockets on the same machine reliable?

If i use UDP sockets for interprocess communication, can i expect that all send data is received by the other process in the same order? I know this is not true for UDP in general.
Lothar
  • 12,537
  • 6
  • 72
  • 121
31
votes
4 answers

'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS

I'm using Visual Studio 2015 and attempting to compile code that has worked before I updated from VS 2013. 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS in this code: partner.sin_addr.s_addr =…
The Count
  • 311
  • 1
  • 3
  • 8
28
votes
5 answers

Boost::asio winsock and winsock 2 compatibility issue

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…
Dainius Kreivys
  • 525
  • 2
  • 8
  • 19
28
votes
4 answers

How to flush route table in windows?

I am trying to write a program that changes the default gateway of network time by time. But it seems that there are caches on the route table in every process so that I cannot control the network behavior accurately. Can I just flush route table to…
jay
  • 1,032
  • 2
  • 13
  • 20
26
votes
3 answers

How to link winsock.lib?

In my C++ class, I use sockets. I have some errors when linking because, in my opinion, the library winsock.lib is missing. I included these: #ifdef WIN32 #include typedef int socklen_t; typedef char raw_type; …
Safari
  • 11,437
  • 24
  • 91
  • 191
23
votes
3 answers

Is there a difference between and ?

I'm including as it's required by the MySQL C library. The auto-complete in VS2010 is also showing a - any idea what this is? Are they interchangeable, and are there any advantages of one over the other? Thanks!
James
  • 1,430
  • 4
  • 20
  • 27
22
votes
4 answers

Converting C++ TCP/IP applications from IPv4 to IPv6. Difficult? Worth the trouble?

Over the years I've developed a small mass of C++ server/client applications for Windows using WinSock (Routers, Web/Mail/FTP Servers, etc... etc...). I’m starting to think more and more of creating an IPv6 version of these applications (While…
NTDLS
  • 4,757
  • 4
  • 44
  • 70
22
votes
7 answers

What is the workaround for TCP delayed acknowledgment?

I have shipped an online (grid-based) videogame that uses the TCP protocol to ensure reliable communication in a server-client network topology. My game works fairly well, but suffers from higher than expected latency (similar TCP games in the genre…
Mr. Smith
  • 4,288
  • 7
  • 40
  • 82
22
votes
1 answer

how to link winsock in cmake?

I found only this strings find_library(WSOCK32_LIBRARY wsock32) find_library(WS2_32_LIBRARY ws2_32) (i'm begginer in cmake) how to link winsock2 (winsock?) in cmake?
Fedcomp
  • 2,175
  • 5
  • 21
  • 23
1
2 3
99 100