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

How long does a UDP packet stay at a socket?

If data is sent to the client but the client is busy executing something else, how long will the data be available to read using recvfrom()? Also, what happens if a second packet is sent before the first one is read, is the first one lost and the…
T.T.T.
  • 33,367
  • 47
  • 130
  • 168
19
votes
6 answers

Delphi, How to get all local IPs?

Any one know a way in delphi get a simple list (eg tstrings) of the local ip address. I have had a look at the other related question, and cant seem to get my head around converting them to delphi.
Christopher Chase
  • 2,840
  • 6
  • 36
  • 57
19
votes
5 answers

C - Undefined Reference to WSAStartup@8'

I am using Code::Blocks, MinGW, and Windows. Im trying to initialize the winsock so that I can work on a project. I keep getting the error Undefined Reference to WSAStartup@8 Anyone know how to go about fixing this? #include #include…
Paulo
  • 191
  • 1
  • 1
  • 4
18
votes
4 answers

How can I check if a client disconnected through Winsock in C++?

How can I check if a client disconnected through Winsock in C++?
Sasha
18
votes
4 answers

How to set up a Winsock UDP socket?

I want to create a Winsock UDP socket that only sends data to a client. I want the kernel to choose an available port for me. On the other hand, I want to indicate which local IP to use, since I'm running a few nics. I've tried combing through the…
axs6791
  • 687
  • 1
  • 6
  • 12
18
votes
1 answer

How does WSAStartup function initiates use of the Winsock DLL?

How does WSAStartup function initiates use of the Winsock DLL? According to the documentation The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the …
Searock
  • 6,278
  • 11
  • 62
  • 98
17
votes
3 answers

Substitute for forking in windows

I've been following Beej Networking guide and in the server section there is portion of code where it has called a function fork(). if (!fork()) { // this is the child process close(sockfd); // child doesn't need the listener …
silent
  • 2,836
  • 10
  • 47
  • 73
17
votes
6 answers

winsock compiling error, it cant find the addrinfo structures and some relating functions

I've just started learning winsock through the "Beej's guide to network programming" book. I'm programming under windows and running it through gcc. This is just a start to writing my first server program but it gives me these errors when I try to…
silent
  • 2,836
  • 10
  • 47
  • 73
16
votes
2 answers

Rejecting a TCP connection before it's being accepted?

There are 3 different accept versions in winsock. Aside from the basic accept which is there for standard compliance, there's also AcceptEx which seems the most advanced version (due to it's overlapped io capabilities), and WSAAccept. The latter…
sold
  • 2,041
  • 5
  • 25
  • 32
16
votes
1 answer

Do I need to close a socket?

After sending data over a socket with Winsock, you're supposed to close the connection like this: closesocket(ConnectSocket); WSACleanup(); I'm writing an API that sends data over a socket. If I have to close the socket afterwards, I need to add a…
1''
  • 26,823
  • 32
  • 143
  • 200
15
votes
4 answers

Determine between socket and fd

On unix everything is a file approach of function read(), write(), close() is not supported on Win32. I want to emulate it but have no idea how to distinguish when sock is socket or fd on WinSocks2. //returns 1 if `sock` is network socket, // …
DinGODzilla
  • 1,611
  • 4
  • 21
  • 34
15
votes
4 answers

git pull fails with "Either the application has not called WSAStartup, or WSAStartup failed"

I have just installed Windows 10, Visual Studio Community 2015, and Git for Windows. I also installed the latest Bitbucket and GitHub extensions. Within Visual Studio I cloned my Bitbucket.com-hosted repository, and performed these operations…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
14
votes
4 answers

Is it possible to host a webserver in VBA?

I want to host a web server and want to use VBA to do it. Is this possible? I'm just doing this to prove someone wrong and really want to make this program. So is it possible to make a really simple web server (just listens for get requests)? Help…
David
  • 141
  • 1
  • 3
14
votes
4 answers

Porting Winsock to Linux Sockets

I have a program that does some networking using Winsock, and one of our requirements right now is to port over our program to Linux. The only thing stopping us from doing this is Winsock. My question is: How easy can I port this over to a Linux…
Mike Bailey
  • 12,479
  • 14
  • 66
  • 123
14
votes
4 answers

Why are there WSA pendants for socket(), connect(), send() and so on, but not for closesocket()?

I'm going to try to explain what I mean using a few examples: socket() -> WSASocket() connect() -> WSAConnect() send() -> WSASend() sendto() -> WSASendTo() recv() -> WSARecv() recvfrom() -> WSARecvFrom() ... closesocket() -> WSA???() This is…
Oliver Baur
  • 2,295
  • 2
  • 16
  • 7