Skip to main content

All 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 ...
Abe164's user avatar
  • 1
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 ...
Junhui Zhu's user avatar
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 - /...
Dfr's user avatar
  • 4,185
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....
Thomas Briggs's user avatar
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 ...
user3740951's user avatar
  • 1,259
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 = {}; ...
Carson Schubert's user avatar
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?
vaishali jhalani's user avatar
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 ...
doubleA's user avatar
  • 103
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 ...
Darshan L's user avatar
  • 975
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 ...
pepero's user avatar
  • 7,513
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 ...
Bipul Adh's user avatar
  • 113
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 ...
lz96's user avatar
  • 2,998
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() { ...
hermancain's user avatar
  • 1,632
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, ...
Boson Rao's user avatar
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 ...
Benji Mizrahi's user avatar

15 30 50 per page