I have a c program to create a TCP socket and keep waiting for a connection in an infinite loop. Each time a client connected to the program, I would spawn a new child process to handle the client request. My program could only exit with signal interrupt (e.g. ctrl+c). I don’t want the parent process hanging there and wait
Tag: sockets
How can I create a TCP connection in Python between 2 PCs
So far I have made a VERY basic client/server application that creates a TCP connection. I have a lot of programming experience, just never did this low-level stuff and especially nothing with networks. Note that all the prints are just to help me figuring out what is going on. One of the known issues is that jsonip sometimes gives me
Linux Socket timeout works on WSL, but not on Ubuntu
I try to run a TCP client without a server. The idea is simply to periodically try to connect. For this, the client tries to connect to port 1500 on localhost. Piece of code: I’ve set it up in Ubuntu 18.04 on WSL. There, the code waits on select for the defined timeout of 2 seconds and returns appropriate return
(Socket operation on non socket) error while trying to receive data on a TCP server
What I want to do is send a message (which I type on the terminal) from the client to the server. I’m getting this error on the server when I try to call the recv() function. As you can see, the client doesn’t show errors. This is the code I’ve written for the server side: I’m confused because I’m already
How to check if the IP address that a socket is bound to is still one of the valid machine’s addresses?
Once I call socket(); bind() (with a specific IP address, not INADDR_ANY); listen(), there seems to be no way of determining if the IP address is still a valid address of one of the system’s interfaces. What I looked into using: Checking error with getsockopt(SO_ERROR); Using epoll()-ing on some EPOLLERR, EPOLL{,RD}HUP events; Hoping that accept() would return an error if
Meaning of adding 1 on socket file descriptor in select function when using linux socket
What is the meaning of adding 1 on socket file descriptor when using in select function? I create socket file descriptor like below, and use it in select function like below, What is the meaning of +1 in select function? It even does not work when I remove the calculation adding the value. Thanks in advance. Answer RTFM! The first
C sockets
The following C program calls select() to get a list of client sockets that have data in the socket buffer (using UNIX domain datagram sockets). It takes four parameters on call from a NASM program. The parameter fds_array[] is a 3-element integer array created in NASM and passed into the program. The data are passed in from NASM in rdi,
Control doesn’t move next to the select function
i am trying to implement a TCP server that accepts multiple client nodes. However, the control is just stuck at select() and not moving beyond that. This is my code: However, the control never moves beyond the select statement. It just remain there even after i open a connection to the server with telnet: Why it stuck there and how
BPF: `bpf_obj_get_info_by_fd` fails with `Invalid argument`
I try to get the fd of the BPF_MAP_TYPE_XSKMAP in my user-space program. This is the code: But unfortunately, I get an error for calling bpf_obj_get_info_by_fd(cfg->prog_fd, &prog_info, &prog_info_len): Failed to obtain prog_info 1: Invalid argument. I don’t know if this is because the XDP-program is loaded from another process? Does the same process have to obtain program information which also
What happens to TCP socket when IP address changes?
Is there any error on a socket when writing to it after IP address change? In my I’m using TCP socket, both read/write (non-passive), no TCP or application keep-alive. To inspect this case I use socat to connect to a simple echo server on my local network. The connection is OK until I change the client IP address on my