All Questions
Tagged with unix-socket network-programming
35 questions
0
votes
0
answers
671
views
How to handle TCP and UDP sockets binded to the same port in a server written in C? [duplicate]
I am a novice UNIX socket programming learner and I would like to inquire some advice on writing a server that can handle both TCP connections and UDP datagrams on the same port with a server written ...
0
votes
1
answer
460
views
Which layer is Unix socket on?
I am trying to use Unix Socket to implement IPC and I know that Unix Socket is much more faster than TCP, but I still have 2 questions.
Is Unix Socket reliable as TCP?
Which layer is Unix Socket on ...
2
votes
1
answer
229
views
Python unix sockets doesn't work ? Can't find any explanation here
I have running mpv player which supports IPC control throught unix sockets, and it works shiny well:
$ echo '{ "command": ["set_property", "pause", true ] }' | socat - /...
0
votes
1
answer
74
views
Unix networking in C++ doesn't wait for a connection
I have recently been learning about networking in Unix, and have written these 2 simple programs that waits for a connection, receives a message, then sends the same message back to the sender:
Send....
1
vote
1
answer
536
views
SOCK_DGRAM socket recv thread-safe?
Are UNIX SOCK_DGRAM sockets thread-safe for recv() method?
If multiple threads are calling recv() on socket, are both guaranteed to get one clean UDP packet each or is there a chance of data getting ...
0
votes
0
answers
403
views
C++: Setting network interface down does not cause linux sendto() function to fail
I have a nonblocking socket created as:
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
fcntl(sockfd, F_SETFL, O_NONBLOCK);
It is then connected to the server via:
struct sockaddr_in addr = {};
...
2
votes
1
answer
1k
views
Throughput and Latency of a Unix Domain Socket used by a process
My Linux machine consist of a process which is using Unix Domain Socket. How can I calculate the throughput and Latency of that domain socket. Is there any tool that I can use?
0
votes
1
answer
185
views
Implementing new routed protocol in python
I'm trying to build a simple router prototype in python with which I could test new routed protocols; let's say newly made up IPv7. From what I understood I cannot use sockets (socket.AF_INET) without ...
0
votes
1
answer
2k
views
What are the reasons socket creation can fail?
I am creating a socket with the parameters as below-
fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
But for some reason socket creation is failing and fd is set to -1.
I wanted to understand for ...
0
votes
1
answer
760
views
getsockname() without bind()
I'm trying to get the port number of the socket, without calling bind().
The code is as follows.
#include <arpa/inet.h>
#include <unistd.h>
#include <cstdio>
int main() {
int ...
0
votes
0
answers
54
views
Networking and multihreading in C++. Errors and how to make my code design better?
I am trying to create a simple local server that accepts connections on a different thread. I am trying to create a simple backup program for my files(kinda a like dumbed down cloud for my house). I ...
0
votes
0
answers
132
views
What does 'may fail' in socket() mean?
The socket() function shall fail if:
EAFNOSUPPORT
The implementation does not support the specified address family.
EMFILE All file descriptors available to the process are currently ...
2
votes
1
answer
3k
views
Send JSON to a unix socket with golang
I'm trying to write a golang program to control mpv via issuing commands to a unix socket running at /tmp/mpvsocket.
This is what I've tried so far:
func main() { ...
3
votes
1
answer
490
views
Close a socket by call both shutdown and close
I saw a piece of code like this, which was used to close a socket.
`//a TCP socket is created: sockfd
struct linger ling;
ling.l_onoff = 1;
ling.l_linger = 0;
setsockopt(sockfd, SOL_SOCKET, ...
1
vote
2
answers
309
views
Cannot get the available bytes from the unix domain socket
I am sending N bytes from a unix domain socket (AF_UNIX, SOCK_DGRAM) to another. However, if I read X bytes from the other socket, where X < N, a subsequent call to read() blocks and I cannot get ...