996 questions
4
votes
1
answer
239
views
How to FIX printf resulted SIGSEGV when compiled with openssl?
I am trying to compile my code with openssl library. My code is printf then the program received SIGSEGV signal.
Code of test.c:
#include <winsock2.h>
#include <openssl/ssl.h>
#include <...
0
votes
1
answer
131
views
WinSock2 "recv" never reading all data
I'm trying to transmit a large chunk of data using WinSock2 from my Ubuntu Server (running wine) to my Windows Client.
This is the client code:
int expected_length = 0;
recv(m_Socket, (char*)&...
0
votes
1
answer
75
views
System (PID 4) listens on my port after I close the listening socket
On Windows Server 2022 I'm running a custom HTTPS server (part of a larger app). The service binds, listens and then accepts on port 81 for a while and netstat -abn shows:
TCP 0.0.0.0:81 ...
1
vote
1
answer
137
views
Windows RIO/UDP with IOCP: Issue in getting GetQueuedCompletionStatus to work
I have a console app where I'm working through setting up a UDP listener using RIO. I started with simple polling to test the flow between a simple console client and the console app/server. I can ...
0
votes
0
answers
47
views
WinSock2 - Socket cannot be read any longer if there was no data for a period of time
I'm using a socket to retrieve image data from a camera. This works properly, if the camera is continuously sending data. But, when the camera is in manual trigger mode and we wait for a while (maybe ...
1
vote
1
answer
74
views
How to retreive IP interface DNS suffixes using winsock2? [duplicate]
In Windows, for a interface, you can set DNS suffixes to add to queries.
How do one retrieve the settings dom1.com, dom2.com using winsock2?
If I call GetAdapterAddresses the IP_ADAPTER_ADDRESSES_LH ...
-2
votes
1
answer
88
views
How can I filter incoming connections?
I have this select waiting for data in the socket buffer. When there is data in the buffer, I launch a thread and accept the connection.
while (!InterruptWaitForConnections)
{
const int status = ...
-2
votes
1
answer
66
views
C++ Winsock UDP Port Wont Bind
I'm writing a bit of code that can listen for UDP messages via Winsock.
The port bind works on local loopback (127.0.0.1) but when I try to change to any other IP the bind fails.
Is there something I'...
0
votes
1
answer
174
views
Running the Microsoft Winsock Client and Server Code Sample
I've downloaded and successfully compiled the Microsoft Winsock Client and Server Code Sample from here. This client server combination application both work just fine running on the same computer. ...
0
votes
1
answer
79
views
Socket in C++ : Handle multiple concurrent request in Windows OS
I try to build a multi thread server so when there is multiple concurrent request, the server can handle them at the same time. But, my code still require for waiting first request to be done before ...
1
vote
1
answer
74
views
WinSock2 accept function causes access violation when used in multiple threads of one process
I am working on designing libraries in C and C++ for my company's proprietary language through ffi. The two libraries which are causing the problem related to the title are the threads and sockets ...
1
vote
1
answer
308
views
Allow Type of Service / DSCP Marking on Windows for a network socket
I'm looking to programatically mark the Type of Service / DSCP byte in packets from a network socket. The current implementation in C# is below:
UdpClient udpClient = new UdpClient();
string ...
0
votes
0
answers
43
views
How to handle if the fd has read and write at the same using select in winsock?
I saw some code examples to explain select() can handle multiple events at the same time as below:
FD_SET readfds;
FD_SET writefds;
FD_SET exceptfds;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
...
2
votes
0
answers
132
views
Unable to recv data that recv(PEEK) returned
I was debugging some 64 bit, native C code using WinSock2 for TCP and after eliminating all of the errors I expected, I found out that WinSock2 was doing something I did not expect. Simplified for ...
2
votes
1
answer
116
views
does windows networking code break the strict aliasing rules?
As I was told here: can you typecast an int into 4 chars using structs?, typecasting a struct into another struct pointer is against the "strict aliasing rules". But I think that in C ...
0
votes
2
answers
80
views
what is the purpose the asterix after SOCKADDR in: bind(ListenSocket, (SOCKADDR*) &s, sizeof(s));
I haven't found an explanation to why you would put an asterix after a variable.
This is the example:
int main(){
WSADATA Winsockdata;
WSAStartup(MAKEWORD(2,2), &Winsockdata);
int ...
0
votes
2
answers
294
views
Error transfering files to Android using Windows C++ Bluetooth OBEX socket
OBEX is probably the most commonly used technique to transfer files over devices that support Bluetooth. On the contrary , with being the most common , it is not very well documented how this thing ...
0
votes
0
answers
69
views
QTcpServer stop accepting new connections
I'm caught by a strange problem.
A listening QTcpServer that is working normally suddenly stops accepting new connections (qBittorrent webui stop working).
I did a little digging into Qt's source and ...
1
vote
0
answers
27
views
Implementing a Matlab Reader using winsock2 and DLL library
I am trying to interface Matlab with a C code that I used to read data through UDP.
I am using the winsock2 library, and compiling the C code into a DLL file for it to be loaded into Matlab. My C code ...
0
votes
1
answer
227
views
WSAGetLastErrror returns 0
I'm creating a project using winsock2's sockets
I'm using a syscall to connect to a socket on a local IP address, then I implemented a simple method for error handling purposes.
// Client-side
int ...
0
votes
1
answer
92
views
recv doesn't work in a thread - Windows c++
I'm currently developing a TCP server and I use multi threading, so for this I init a server using a Server.start() which give me a fd like and then I init an infinite loop to accept and start new ...
0
votes
0
answers
70
views
I have an issue creating a server socket on c++ for listening the connections via internet
I tried to make a server socket for connecting client sockets via internet. I found nothing in google.
Unfortunately, it works only with my local network. It responds when I connect to 127.0.0.1 ...
0
votes
0
answers
32
views
Winsock Server Bind failed 10047 [duplicate]
Server code
#pragma once
#include <WinSock2.h>
#include <tchar.h>
#include<WS2tcpip.h>
#include <map>
#include <string>
#include <iostream>
/*
struct sockaddr_in {
...
1
vote
2
answers
286
views
Invalid IP address with InetPton() function
I am using the Windows OS and am coding in C, currently.
I am a complete beginner in socket programming, and have this following piece of code that is returning unwanted values.
(MAXLINE = 4096), and ...
-1
votes
1
answer
121
views
winsock2 socket connection works within local pc, but not from remote pcs
I'm trying to learn low level networking in c, and have gotten as far as making TCP client and server programs that make, bind, connect, accept, etc. sockets using winsock.
They work just fine, and my ...
-2
votes
1
answer
280
views
UDP client - server on Windows , one thread to receive and another to send
I can send and receive data on different threads using the TCP protocol as demonstrated in the following code, how can I do the same using the UDP protocol?
#include <iostream>
#include <...
0
votes
1
answer
207
views
sending data through a TCP socket, not received correctly
Hello everyone I need to convert std::vector<uchar> to const char* or send std::vector<uchar> over socket using winsock2.h in windows system.
How can I do this?
I'm compress one image:
std:...
-1
votes
1
answer
213
views
Winsock2 Sending a File using Bluetooth OBEX Object Push Profile (OPP)
I want to implement the function 'Send a file' in the image
enter image description here
I want to implement step 4 in the link Send files over Bluetooth in Windows
I set the guid below,
...
0
votes
1
answer
201
views
recv function from winsock.h, i don't understand how it works
I'm a beginner. The function requests the following parameters:
int recv(
[in] SOCKET s,
[out] char *buf,
[in] int len,
[in] int flags
);
The second parameter requests me to pass ...
0
votes
0
answers
16
views
HTTP Request in C [duplicate]
i'm coding a http request library for a project. I'm using winsock2's sockets to create http requests and i don't know what i'm doing wrong. There is not much on google about http requests in c so i ...
0
votes
1
answer
131
views
connect-function (winsock2.h) doesn't find Host
I'm currently trying to understand how to establish a server-client connection under Windows using the header file "winsock2.h". I have done the "Getting started" from Microsoft (...
0
votes
1
answer
514
views
When connecting (winsock2) socket i get error 10038 [closed]
Hello, i'm coding a client with sockets (i usually do that in unix but i wanted to try in windows) with the winsock2 library. When i'm connecting the socket to an ip i get error 10038. I googled msdn ...
1
vote
2
answers
105
views
Unable to run client/server socket programs on Windows, programs exit immediately
I compiled both client and server code using the following commands:
server : gcc server.c -o server.exe -lws2_32
client : gcc client.c -o client.exe -lws2_32
Both codes are successfully complied and ...
1
vote
1
answer
345
views
TCP client on Windows cannot bind() to port < 1023
I'm doing some testing with a TCP client on Windows 10 (10.0-19045) but due to firewall restrictions I need to run my experiments from a local port < 1024 (not negotiable).
I thought that this was ...
0
votes
0
answers
242
views
Winsock2 based TCP client with GUI (how to combine TCP console application with GUI)
I have a console application running as a TCP client using Winsock2. This application connects to a server which regularly provides measuring data, and needs to get some configuration from my client. ...
0
votes
0
answers
214
views
What is the point of specifying SOCK_STREAM and IPPROTO_TCP in getaddrinfo if both refer to a TCP connection?
I'm revisiting winsock after all these years with fresh eyes and can't seem to understand why SOCK_STREAM and IPPROTO_TCP are both necessary to specify in the pHints parameter of getaddrinfo:
INT ...
3
votes
1
answer
368
views
Win32 getaddrinfo() not using C:\Windows\System32\drivers\etc\hosts?
Does Win32 getaddrinfo() use C:\Windows\System32\drivers\etc\hosts?
We want to use C:\Windows\System32\drivers\etc\hosts to specify IPv6-only addresses (which are NOT part of the DNS), and let our ...
1
vote
1
answer
108
views
Winsock2: Using connect() to connect to server, but from tcp port < 1024?
Does Winsock2 have an API to define which TCP port a client uses to connect() to a server?
We need to connect() to a UNIX server, which only responds if the client TCP port is < 1024 (Reserved ...
0
votes
0
answers
148
views
Which data types should be used for Bytes sent in C++ socket/network programming?
I wonder which data type is the most suitable for representing bytes I send via Windows API winsock.
I'm currently working on receiving and sending data frames on network sockets, as well as a CAN ...
0
votes
1
answer
127
views
C++ HTTP server file downloader problem with Ajax uploader
For some reasons and educational purposes, I developed myself a C++ HTTP server from scratch which should capture file uploads from an HTML page with AJAX handling dynamic requests and save it in the ...
0
votes
1
answer
148
views
Winsock2 missing some macros and functions that are defined in the documentation
I'm programming a multithreaded server in windows using winsock2 (linking with ws2_32.lib and pthread), but am having trouble trying to set a socket to persistently triggered mode.
Thanks :)
I've ...
0
votes
1
answer
396
views
Is there a way to connect to an encrypted TCP server using Winsock?
Winsock docs mentions IPsec secure extension for sockets but it does not mention SSL anywhere, Is there a way to use SSL with the created socket without using third party libraries such as OpenSSL or ...
1
vote
1
answer
271
views
where is WSASocket defined?
I am trying to dynamically link winsock functions starting with WSASocket, the following code compile just fine
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
typedef ...
-1
votes
1
answer
286
views
How to fix a connection issue with my C++ Client?
Everytime when I've tried to use my client to connect to the server on port 2997, it simply didn't work. Nothing happens, no message confirming and no error message. I executed the client as Admin on ...
0
votes
1
answer
133
views
WSA 10037 with no apparent cause
I've been trying to write a simple server-client connection using Winsock2. I've written similar server-client code before and have copied and pasted the same code from a previous project I made, I ...
0
votes
1
answer
180
views
I can no longer create a server listening on port 64951 or 64952 under Windows 10 [duplicate]
I can no longer create a server listening on port 64951 or 64952 under Windows 10.
I got an exception on my C# program when I tried to bind to 0.0.0.0:64951.
Same on a C++/Qt program, the error is : '...
0
votes
0
answers
334
views
Increasing buffer size in setsockopt not reflected during runtime in WIndows
I've been trying to increase the size of the socket buffers (specifically the receive side buffers for UDP packets) using the winsock2 setsockopt function as such:
u_long iMode(1);
handle = socket(...
0
votes
1
answer
53
views
How exactly sockets are handled in C on windows?
So, I'm having a problem, I'm trying to do a simple c server-client, where basically a client connects to the server, and from time to time the server pings the client, shouldn't be this complicated, ...
1
vote
1
answer
177
views
TCP SYN RAW socket receive packet error 10022
I'm porting my program from Unix to Windows, and I have a problem with the recvfrom() function to accept a packet. I haven't written anything with Winsock until now. I think I've done everything, ...
0
votes
0
answers
38
views
Issue receiving message from client
I wrote a server app using winsoch2.h to serve as a group chat server using single thread. It is a console application.
I wanted the app to accept multiple clients trying to connect to the server, ...