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
0
votes
0 answers

download a file using C Socket Programming

I need to transfer .txt file using sockets. I try this: Server: #define CHUNKSIZE 1024 FILE* fd = fopen("download.txt", "rb"); size_t rret, wret; int bytes_read; char buffer[CHUNKSIZE]; while…
0
votes
0 answers

recv() always returns 0 when trying to send HTTP POST request

I am trying to use HTTP post request to get the location info from google geolocation API but something is going wrong with the connection after I send the query i get 0 as return value for recev() Is the way am sending post request the issue? why…
siva
  • 1
0
votes
1 answer

How to get IPv4 address from SOCKADDR structure?

I can't figure out how to get the actual IP v4 address (e. g. 192.168.1.1 or its corresponding packed form as a 32-bit integer) from the Address field of IP_ADAPTER_UNICAST_ADDRESS_LH structure. I went down the rabbit hole of the linked lists and…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
0
votes
0 answers

C++ Winsocks, recv(socket,512,0) only receiving one char at a time

For some weird reason, I initialize the sockets: void init() { cout << "\t\t-----TCP SERVER---" << endl; cout << endl; //STEP 1 WSAStartup iwsastartup = WSAStartup(MAKEWORD(2, 2), &Winsockdata); if (iwsastartup != 0){ …
Samuel
  • 209
  • 1
  • 9
0
votes
1 answer

WinSock c++ inet_ntop always displays 204.204.204.204 (and accept() didn't failed)

I'm trying to make a winsock server and I want to display the client's ip on the server when he connects but that's where there is a problem. Every time I try to connect it display 204.204.204.204. I tried to connect with another computer but the…
MatGeneral
  • 57
  • 6
0
votes
0 answers

I can only receive one word (winsock c++ tcp/ip server and client)

I managed to create a tcp server and client with winsock in c++ but for a reason that is unknown to me I can not send more than one word at a time. see by yourself: I specify that I am an absolute beginner and that my code probably contains errors…
MatGeneral
  • 57
  • 6
0
votes
1 answer

Serializing a class that contains a string, to send it over a network through a socket?

I'm experimenting a little bit with the winsock library, by creating a pretty simple server-client connection. The client should send messages to the server, which should forward them to all the clients. Each client should only print a message if…
Alex
  • 1
  • 1
0
votes
0 answers

Running on Ubuntu for Windows IIS Server, the C code returns -1 for recv()

I have a IIS Server running on Windows 10 and the following code is getting executed from CLion IDE for C on Ubuntu. The program stuck always at recv() throwing -1 as the value. I am able to get the response from the server using curl so I am able…
Ujjawal Sharma
  • 63
  • 1
  • 1
  • 7
0
votes
1 answer

How to send double-type data via TCP/IP Winsock

I'm trying to send sensor data (double type) from client to server via TCP/IP (Winsock). In theory, after connected successfully, we will execute the command send(). I use 2 variables: stringstream ss and string res to store sensor data and convert…
Hector Ta
  • 81
  • 2
  • 14
0
votes
0 answers

Send string via Winsock fails

I want to send some text from Client to server, but the receiver just hangs and nothing goes thru. Client program client; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes , SysUtils, Windows,…
Magnum
  • 1
0
votes
1 answer

Simple non-blocking multi-threaded tcp server

I'm studying C++, and this weekend I started to play around with sockets and threads. Bellow is a simple multi threaded server that I'm making based on some tutorials. The issue that I'm facing is that when I'm connecting with 2 telnet clients only…
0x_Anakin
  • 3,229
  • 5
  • 47
  • 86
0
votes
1 answer

Send string to HDFS via Winsock

I am currently implementing a C program which schould send a test string to the HDFS cluster by using the Winsock2 library. The HDFS listens on Port 9999 and the IP-Address is 10.32.0.91 (I use this IP-Address to connect to the HDFS shell via…
user7335295
  • 401
  • 2
  • 7
  • 31
0
votes
0 answers

Why I have a problem with the connection? c# winsock error System.Runtime.InteropServices.COMException: 'Excepción de HRESULT: 0x800A9C54'

I'm making two projects: "server" and "client". I want to make a chat room using winsock and C# but the following exception is thrown when I click the button "btnconnect" in "client": System.Runtime.InteropServices.COMException: 'Excepción de…
0
votes
1 answer

Winsock TCP Packets sent but not reaching host

When the server sends 4 or more - 25 Byte packets to the client only the first 2 are processed by the client. I am using Event select on the client, and send on the server. There are no errors but only the first 2 packets are displayed. Thanks in…
erai
  • 185
  • 1
  • 11
0
votes
1 answer

winsock client repeatedly try to connect to server

I'm learning winsock programming. I have a question about the code provided in msdn: https://learn.microsoft.com/en-us/windows/desktop/winsock/complete-client-code #define WIN32_LEAN_AND_MEAN #include #include #include…
Duy
  • 45
  • 1
  • 4