Questions tagged [winsock2]
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
933
questions
-4
votes
1
answer
30
views
Networking or sockets for windows [closed]
Is there any documentation for winsock2.h for c because when i try to compile compiler says in very short that im idiot and im compiling for wrong language i don't want to code for linux environment ...
0
votes
0
answers
24
views
Problem with accept() in winsock server when run in a separate thread
I use the simplest implementation of the winsocket server taken from the Microsoft page:
https://docs.microsoft.com/en-us/windows/win32/winsock/complete-server-code
(I named the server function int ...
-1
votes
0
answers
28
views
Asynchronous winsock server is still blocking
I'm trying to create the winsock server which runs asynchroniously with another application.
I found the following minimal example of the asynch winsock server:
#include <iostream>
#include <...
0
votes
0
answers
30
views
WinSock check if recv timeout is over
Suppose WinSock recv function timeout is over. How can I check it programmatically? The only idea I can come up with is to measure time it's taken for recv to execute with standard time measurement ...
0
votes
0
answers
16
views
WinSock check on the server side that the timeout on the client side is over
Suppose there is a recv function on the client side which expects some confirmation message from the server, and this function has a particular timeout. If this timeout is over, how can the server ...
0
votes
1
answer
43
views
the return value of WinSock lpfnAcceptEx
I want to know when will lpfnAcceptEx return TRUE
This is the description of the official documentation:
If no error occurs, the AcceptEx function completed successfully and a
value of TRUE is ...
0
votes
0
answers
50
views
Winsock2.h trouble
when I compile this program and run it, I get the output below. I added the bind failed with error output for debugging and it suggests that with the error code that I received from listen the socket ...
0
votes
1
answer
28
views
Get WSAEFAULT error when I use getsockname
When I run following code, I always get WSAEFAULT error. Not sure what am I doing wrong? Any help will be appreciated. Thank you.
uint8_t status = ICRON_OK;
struct sockaddr_in serverAddr, clientAddr;
...
-1
votes
1
answer
21
views
c++ TCP client and server not able to communicate on local machine
I have built a simple c++ TCP server and client using winsock. The code all compiles without error however either the server is refusing connections or my client is failing to connect properly.
The ...
0
votes
0
answers
27
views
Detecting own message when sending UDP broadcast
My program (C++, winsock, Windows 8, 10) sends UDP broadcast message to invite other computers to make connection via TCP.
Therefore, the program receives this (own) message just like other computers ...
-1
votes
0
answers
54
views
low speed of UDP sockets (c++ winsock)
What I'm trying to achieve
I'm trying to make socket app where server would take screenshot and send it then client would recive it and display.
How it should work
In order to do so I use UDP sockets (...
1
vote
1
answer
27
views
Winsock2 receiving data from multiple clients without iterating over each client
I use winsock2 with C++ to connect thousands of clients to my server using the TCP protocol.
The clients will rarely send packets to the server.... there is about 1 minute between 2 packets from a ...
0
votes
2
answers
96
views
Why I am unable to verify the downloaded google's certificate in my C programm?
I downloaded the google's certificate in linux (I am using mingw for cross compilation and wine for execution):
mkdir -p ./release/certificates
echo | openssl s_client -servername google.com -connect ...
0
votes
1
answer
58
views
Why does SSL_get_error return SSL_ERROR_SYSCALL?
I attempt to perform an HTTP GET request via winsock2 usin openssl 1.1.1 as SSL Layer:
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <winsock2.h>
#include <...
0
votes
2
answers
50
views
C4267 warning when trying to send data over socket in C
My program will only run on Windows machines. I got multiple warnings, all the same. This is the warning:
Warning C4267 'argument': conversion from 'size_t' to 'int', possible loss of data
I get ...
0
votes
1
answer
51
views
How to tell if a client is attempting to connect to server in c++ winsock
I want a server to accept a client with this code
SOCKADDR_IN cliaddr = { 0 };
int len = sizeof(cliaddr);
_sockClient = accept(_sockServer, (SOCKADDR*)&cliaddr, &len);
Both _sockClient and ...
0
votes
1
answer
13
views
Assign SOCKET value by reference to address
Is it possible to pass a SOCKET as a pointer to a function that uses accept function and assgin the value returned from accept by dereferencing the pointer
int accepter(SOCKET soc, SOCKET & agent) ...
0
votes
1
answer
29
views
How to deal with SOCKET in select method?
I saw this example in IBM docs on how to use select method for a server program, I would like to something similar to that on windows without using vectors and unordered_map but the problem I am ...
0
votes
1
answer
32
views
Why is select() not returning back?
I am trying to understand how to use the select() method when dealing with multiple connections in a server program.
int Server::handler()
{
int iResult;
fd_set activeFdSet;
fd_set ...
0
votes
1
answer
28
views
Python Popen hanging during second run of script
# @file Test.py
# Requirement 1
def requirement1():
'''
Requirement 1:
The server will accept command line arguments of:
-a / --address <ip address> -IP address to listen on(...
1
vote
2
answers
108
views
What is the difference between 255.255.255.255 and local broadcast IP? [closed]
I've created a server that listens for broadcast messages from a client that sends them. My local address looks like 192.168.88.***. I tested two cases: clients that send broadcast messages to 192.168....
1
vote
1
answer
101
views
Waiting on sockets using the function WaitForMultipleObjects (msdn)
I am trying to implement a unit test to see if using the function "WaitForMultipleObjects" works properly with socket. To do so I implemented a simple UDP server-client protocol. The server ...
0
votes
1
answer
31
views
Should I think about linked list returned by getaddrinfo when I get addrinfo for my "home" server
I created a server using sockets that runs on my home network. socket address=192.168.88.123:7777
When I call getaddrinfo() function I put "192.168.88.123" as first parameter and "7777&...
0
votes
0
answers
91
views
C++ socket communication with an external device
So I've an industrial controller here and I wish to communicate with this device using my pc (windows 10), over ethernet tcp/ip.
This external device (controller) is connected directly to my pc via an ...
0
votes
0
answers
20
views
Connecting two instances of a program with each working as a server and client at the same time using threads
first time asking here, hope you are all having a great day.
I'm sort of new to network programming in C, but I need to get this done. The idea is to create a chat that has a client and a server each ...
0
votes
1
answer
78
views
How to handle broadcast messages?
I created a client that sends broadcast messages over my local network:
#define SERVER_PORT "7777"
int main(int argc, char** argv)
{
int sockfd;
struct addrinfo hints, *servinfo, *p;...
0
votes
1
answer
59
views
Problems intercommunicating processes in c++ using winsock2
I am having terrible trouble intercommunicating processes, using UNIX sockets. My server is written in c++, but I can't get past calling the bind method.
c++ code.
OutputDebugString(_T("My Sample ...
2
votes
2
answers
121
views
Raw UDP packets via Winsock2 on Delphi
I can build a raw IP packet that contains a UDP packet that contains useful data (DNS request).
I can send it and see that it's sent in Wireshark. Wireshark parses it as a legal DNS request, so ...
-1
votes
1
answer
64
views
Winsock2 drops messages on the loopback network
I made a single server socket that i want to allow multiple connections in a multithreaded fasion but there's an issue. It drops messages from clients for no apparent reason
Each socket is handled by ...
0
votes
0
answers
730
views
Socket error WSAEACCES "An attempt was made to access a socket in a way forbidden by its access permissions" on Private/Home network
I'm getting this error (WSAEACCES) when calling connect function on a TCP socket (destination address is a laptop on the same local network) with my Wifi network profile set as private/home.
When I ...
0
votes
0
answers
25
views
c++ How to add events to WSA socket connections [duplicate]
My goal is to have this be async, so it can be added to an existing pulse code base.
I'm writing this to get a working example that I can then merge into it. Using a windows console app for now.
I ...
1
vote
1
answer
36
views
UDP directed broadcast (WinSock2) failure
Let me start by saying this is my first foray into the world of C after 20+ years of assembly programming for PLCs and MicroControllers.
I'm trying to send a UDP datagram to the network broadcast ...
0
votes
0
answers
67
views
Winsock manually send HTTP request gives 403 Forbidden
I am currently trying to understand how HTTP requests work so I am using winsock2 for c++ to try and send some HTTP requests manually.
My code looks like this:
#include <iostream>
#include <...
-1
votes
2
answers
164
views
winsock2 client return self port number
I'm using lib winsock2 in Visual Studio community, using simple client example.
After executing connect() function, would like to know how can I get/return self/source port number of open connection.
-1
votes
1
answer
116
views
How to make C++ accept ngrok address?
I’ve created a simple C++ program that uses sockets to connect to my other machine. I don’t have windows pro so can’t open port 3389 and I don’t want to download other third party applications as I ...
0
votes
0
answers
32
views
C++ Winsock multithreading [duplicate]
My client program receives and sends data simultaneously upon the same Windows Socket. For these means, I utilize two threads - for reading and writing, correspondingly. To prevent bizarre behavior, ...
0
votes
2
answers
72
views
Undefined struct 'addrinfo' winsock2
I encountered an error and I didn't find any solution (even over the internet)
I created aQt app to receive data using a TCP protocol and plot them using QcustomPlot.
I have the following files:
...
0
votes
1
answer
96
views
C++ undefined reference to 'WSAStartup@8' even though i linked ws2_32.lib
I use CodeBlocks, i've tried #pragma comment(lib, "ws2_32.lib") with and without giving a path, i tried adding it with linker settings, but it still shows the message, i even reinstalled ...
5
votes
1
answer
1k
views
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 <stdio.h>
#include <winsock.h>
int main()
{
WSADATA wsaData;
WSAStartup(...
1
vote
0
answers
69
views
HTTP GET request using C++ WinSock, Binance API
I'm trying first to connect with Binance api endpoint which is /api/v3/ping.
However I'm getting "HTTP/1.1 400 Bad Request" response, what should be updated in this code?
int main()
{...
0
votes
0
answers
56
views
can not recv any multicast data on winsock in cpp
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define MCASTADDR "233.0.0.1" //本例使用的多播组地址。
#define ...
1
vote
1
answer
152
views
Duplicate Windows sockets between unrelated processes
I'm using C and Winsock2 for my learning project.
I have some questions that I hope some one can confirm.
Let say I have 2 unrelated processes, process A and process B ( without using CreateProcess ). ...
0
votes
0
answers
58
views
unwanted recv() fails WSAETIMEDOUT after shutdown on windows
For some unknown reason, windows seemst to activate some kind of 120s receive timeout, when I shutdown the sending side of a socket. Is there any way to avoid it?
This code demonstrates the problem:
#...
0
votes
1
answer
102
views
I can't figure out why recv isn't saving to a buffer
I am creating a TCP Client that can send messages to the server (using winsock2) and in turn the server sends the message to every other socket, but for some reason it recv() isn't getting the data of ...
0
votes
0
answers
101
views
boost.asio + native windows sockets
We have a framework that communicates via native WinAPI sockets (WSASend , CompletionPorts, etc) via TCP.
Recently, we've added some classes to this framework that also async sends and receives some ...
0
votes
2
answers
150
views
Facing an error while sending file chunks through C++ tcp socket on Windows
I am working on a project which should read file as binary chunk and send it to a client.
Server Side code:
FILE *src = fopen("Video.mp4","rb"); // size of the video is 158 MB
int ...
1
vote
1
answer
333
views
Chat room using socket programming with select() - winsock - C
I try to create a server-client application where the server provides a chat service to all clients that connect to the server. The server and client use cryptographic algorithms and protocols to ...
0
votes
1
answer
165
views
Send GET Request in C to IPv6 web server on windows
I am trying to make a simple GET request to a webserver that has an IPv6 address, and it does not work. My code has to be available on Windows, so I use the Windows libraries, e.g.
#include <stdio....
0
votes
0
answers
57
views
Bluetooth connection fails with timeout when using Bluetooth 5.0 dongle
I am currently using this code to discover, then start up a connection with a bluetooth device using the winsock2 API:
constexpr BLUETOOTH_DEVICE_SEARCH_PARAMS btDeviceSearchParameters = {
...
0
votes
1
answer
265
views
Questions about UDP requests in SOCKS5
I have couple of questions about the UDP requests in SOCKS5. I've already read this paper https://www.rfc-editor.org/rfc/rfc1928#section-7 and i'm trying to implement it in C++.
Questions:
Do i need ...