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
13
votes
3 answers

winsock deprecated no warnings

I am trying to create a UDP multicast socket program using VS2015 (C++ console application). I got the following error, Error C4996 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable…
kar
  • 495
  • 1
  • 8
  • 19
13
votes
1 answer

TCP/IP connection on a specific interface

I'd like to connect to a server using one of two network routes. How would one do this? I've Googled quite a bit, and the common answer is to fiddle with the routing table, however this won't help as the destination has a single IP address. Most of…
His Royal Redness
  • 721
  • 1
  • 9
  • 17
13
votes
2 answers

How do I receive udp packets with winsock in c++?

As an attempt at wrapping my head around udp sockets I've tried to port the code from this tutorial page http://www.linuxhowtos.org/C_C++/socket.htm to winsock (running on win 8 if it matters). [direct links below] The code currently compiles and…
Adam Phelps
  • 469
  • 1
  • 5
  • 13
12
votes
6 answers

Ensuring packet order in UDP

I'm using 2 computers with an application to send and receive udp datagrams. There is no flow control and ICMP is disabled. Frequently when I send a file as UDP datagrams via the application, I get two packets changing their order and therefore -…
Davidallencoe
  • 121
  • 1
  • 1
  • 3
12
votes
5 answers

Examples for Winsock?

What do you guys recommend for a resource for winsock? I have an assignment that we have only have a few days to do that needs to send a simple packet using UDP (and receive the same type of packet). I am fairly familiar with C# sockets but nothing…
bobber205
  • 12,948
  • 27
  • 74
  • 100
12
votes
2 answers

Fast detection or simulation of WSAECONNREFUSED

Windows sockets have some strange behavior when it comes to WSAECONNREFUSED (which means backlog full or port not available, see https://stackoverflow.com/a/10308338/851737). If Windows detects one of these conditions, it retries (up to) two times…
schlamar
  • 9,238
  • 3
  • 38
  • 76
12
votes
2 answers

Winsock2.h vs winsock2.h and wsock32.lib vs ws2_32.lib

I am confused about couple of things about winsock. First, what the difference between including Winsock2.h vs winsock2.h (caps of 'w') Second, what is the difference between linking with wsock32.lib with ws2_32.lib? I have tried couple of…
Nick
  • 1,692
  • 3
  • 21
  • 35
12
votes
4 answers

Qt (Creator) with WinSocks (ws2_32)

I want to use an older code-fragment in my Qt-project, which is using WinSocks. I created my program with Qt Creator and I don't know, how I can link to the ws2_32-Library. I already added LIBS += -lws2_32 to my .pro, but nothing happened. So how…
Berschi
  • 2,605
  • 8
  • 36
  • 51
12
votes
1 answer

Get IP-Address from DNS without GetHostByName

I am using GetHostByName to get the IP-Address from a Host/DNS. I also have Kaspersky Internet Security 2013 and noticed that GetHostByName gets picked by it. It seems that that my process tries to create a subkey in…
Ben
  • 3,380
  • 2
  • 44
  • 98
12
votes
2 answers

WinSock.h & WinSock2.h which to use?

Does anyone know the differences between WinSock.h and WinSock2.h . I know they don't use the same library (.lib) but I don't know if WinSock2 only adds new features or if it also improves WinSock 1 features. I am working with IP/TCP sockets and…
Antares
  • 161
  • 1
  • 2
  • 6
12
votes
1 answer

GetQueuedCompletionStatus can't dequeue IO from IOCP if the thread which originally issued the IO is blocking in ReadFile under windows 8

My app stop working after switching to windows 8. I spend hours to debug the problem, found out IOCP behave differently between windows 8 and previous versions. I extract the necessary code to demonstrate and reproduce the problem. SOCKET…
czz
  • 474
  • 3
  • 9
11
votes
4 answers

Sending emails using C

I have just started learning about socket programming and learned about winsock and achieved some progress. my question is basically: I want to send emails, what should I do? points to be mentioned: I learned about initializing winsock. SMTP port…
joker
  • 3,416
  • 2
  • 34
  • 37
11
votes
3 answers

In Win32, is there a way to test if a socket is non-blocking?

In Win32, is there a way to test if a socket is non-blocking? Under POSIX systems, I'd do something like the following: int is_non_blocking(int sock_fd) { flags = fcntl(sock_fd, F_GETFL, 0); return flags & O_NONBLOCK; } However, Windows…
Daniel Stutzbach
  • 74,198
  • 17
  • 88
  • 77
11
votes
3 answers

Windows: Event-based Overlapped IO vs IO Completion Ports, Real World Performance

So I've been looking into overlapped IO for sockets for a server application I'm building, and I keep seeing comments of people saying "never use hEvent" or "IO completion ports will be faster", etc, but no one ever says WHY not to use hEvent and no…
ShadauxCat
  • 211
  • 2
  • 9
11
votes
4 answers

Good lightweight library for HTTP POST/GET for C?

I'm planning of creating a Last.FM scrobbler plugin for a music player in Windows. Last.FM submissions API relays on HTTP/1.1 GET and POST. I've never done Internet oriented programming and I've still to know about the HTTP protocol but I'd like to…
Markus R.
  • 145
  • 1
  • 1
  • 4