Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
56 views

Is there a better way of listening socket in infinite loop in PHP?

I have the following code for listening socket for client connections <?php $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $port = "1234"; socket_bind($socket, '192.168.1.1', $...
Sim's user avatar
  • 19
2 votes
1 answer
43 views

Socket can't find AF_UNIX attribute

I'm using an Arch Linux machine and trying to run the following code from a Python file. import socket import sys if __name__ == "__main__": print(sys.platform) server = socket....
Praanto's user avatar
  • 371
0 votes
0 answers
31 views

Linux Kernel: How to use all ports and avoid WAIT_TIME sockets?

I am building a script for work where I have to scrape massive IP addresses, something like 50 million. However, when analyzing my program and machine performance, we notice the following: At least ...
Adina's user avatar
  • 129
0 votes
1 answer
35 views

How does the socket buffer work in Linux?

I'm using python TCP server, and the clients will just send data to the server via sockets. In Linux, there are the buffer size defined for TCP. So does that mean when the client writes to the socket, ...
Ames ISU's user avatar
  • 341
0 votes
1 answer
103 views

HTTP persistent connection with poll()

On successfully creating the listening socket, I try to run a block of code on it that should maintain a persistent connection. Here is what I have done so far: while(1) { struct pollfd pfds[1]; ...
Artyom Gevorgyan's user avatar
0 votes
0 answers
87 views

Does connect syscall lead to undefined behavior when using nonblocking sockets?

I’m experiencing a very weird behavior in an SSH-like program I’m writing in C for Linux. Code Overview The code is completely nonblocking and designed as a reactor where all fds are registered to a ...
Tal Avraham's user avatar
0 votes
0 answers
26 views

Why is writing a file using Splice slower when done asynchronously?

I'm trying to make a program to write files efficiently from data received in a socket. My approach here is to use the splice Linux syscall, so I made a quick program to do this, and then I tried ...
syzztem's user avatar
  • 72
0 votes
1 answer
77 views

Is this a bug in Linux sockets? Receiving an extra IP header in a RAW udp socket

I created a RAW socket with the UDP protocol, sent a packet consisting of a UDP header and data, everything is fine in the PP, the packet is correct. I also created the same socket in another program, ...
Penguin's user avatar
  • 121
1 vote
0 answers
58 views

Unexpected TCP connection without server binding the port

I'm trying in a loop to connect to a TCP socket as a client. My expectations are that I should not be able to establish the connnection untill the server binds the socket. However, after arrount 15 to ...
MrBKP1's user avatar
  • 11
1 vote
1 answer
109 views

TCP packets don't show up on the server C++

I'm trying to flood a server placed on dstat.cc, but it doesn't work as I expected. Here's the code #include <iostream> #include <thread> #include <vector> #include <sys/socket.h&...
Debug's user avatar
  • 11
0 votes
1 answer
48 views

bind() fails with ENOENT on Unix Domain Socket in Android NDK intermittently on some devices

I'm working on an Android NDK project where I need to bind a Unix domain socket to a path in the app's internal storage. However, the bind() call occasionally fails with ENOENT (No such file or ...
pippocao's user avatar
0 votes
1 answer
44 views

Reverse name lookup with getnameinfo() doesn't work with custom sockaddr_in6

I wrote the following code and expect it to return the address of google.com. However, it returns me an empty string at the end. What do I need to fix to make it work? getnameinfo() gives me the error ...
Artyom Gevorgyan's user avatar
0 votes
0 answers
36 views

Can SO_RCVTIMEO be used for two recvfrom() calls

I have set up a receive timeout like this: struct timeval tv; tv.tv_sec = timeout; tv.tv_usec = 0; if (setsockopt(sock_temp, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)) < 0) { ...
Chris C's user avatar
  • 19
0 votes
0 answers
73 views

How to efficiently send one UDP datagram to 10000 destinations in Linux?

The real scenario: A UDP server has 10000 UDP clients which connected via public Internet IPv4 addresses. The server wants to send one UDP datagram (whose payload size is 1024 in bytes) to the 10000 ...
xmllmx's user avatar
  • 41.2k
4 votes
0 answers
75 views

Why getsockopt with SO_SNDBUF for a TCP socket gives a 1/13 of the value at /proc/sys/net/core/wmem_default?

While doing some exercises about sockets, I wrote the code below. const int socketfd = socket(AF_INET, SOCK_STREAM, 0); int tcprcvbuf; socklen_t tcprcvbuflen = sizeof(tcprcvbuf); ...
Lady Idiot's user avatar

15 30 50 per page
1
2 3 4 5
281