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
Tag: network-programming
Understanding getaddrinfo function in C
I’m new to C and socket programming, just a question on getaddrinfo function. The function prototype of getaddrinfo is: and getaddrinfo returns a result that points to a linked list of addrinfo structures, each of which points to a socket address structure that corresponds to host and service. Below is my questions: Q1-Why it needs to return a result that
Identify virtual network interface in c
I am trying to find which interface my device is running on with C. I scanned all interfaces with ioctl, I arranged the result as : I used getifaddrs() to get list of interfces, then ioctl (IP using SIOCGIFADDR), (flags using SIOCGIFFLAGS) enum net_device_flags, and (mac using SIOCGIFHWADDR). From the list, I can identify the loopback, non-working interfaces that do
How to pick a free port for a subprocess?
I am writing a Python wrapper around Appium server. Appium accepts command-line parameter for a local port to bind to. Unfortunately, Appium cannot autoselect a free port for itself, so it either binds to explicitly specified port, or fails with EADDRINUSE. Even when telling it to bind to port 0, it will start successfully, but won’t display what port it
Be confused with msg_name field in msghdr structure
In user space, I encapsulated a L3 packet using sock_raw (including IP header) and send to kernel space using sock_sendmsg() using msghdr structure I cannot understand clearly the roles of msg_name. I already specified the source IP and dest IP in L3 header. Why do I need msg_name? Answer The msg_name and msg_namelen fields of struct msghdr have the same
Printf makes program work in C, htonl and ntohl not working?
This is for a Linux system, in C. It involves network programming. It is for a file transfer program. I’ve been having this problem where this piece of code works unpredictably. It either is completely successful, or the while loop in the client never ends. I discovered that this is because the fileLength variable would sometimes be a huge (negative
iwlib trying to get access point name – u.addr.sa_data contains suspicious characters resulting empty QString
I have following simple method: Now, I would like to extract Access Point MAC address using this method from wrq structure – its u.addr.sa_data member, which (I THINK SO, AM NOT SURE) containts MAC address of Access Point. Follownig debug screenshot shows value of u.addr.sa_data member: Why am I getting empty QString after ueMACAddress=result>=0?QString(wrq.u.addr.sa_data):”Invalid MAC address”; line of code? Answer
Linux Sockets, how to get number of bytes/packets in sending buffer?
I am working on a simple network application under Linux, where I need to read the following two properties: The number of bytes in receive buffer, which are ready to be read. The number of bytes in socket send buffer, which has not been sent yet. The receive buffer (1st property) could be obtained using FIONREAD option of ioctl() function.
TCP_FASTOPEN cookie is saved per what?
I’ve been reading about TCP_FASTOPEN in Linux and I can’t figure out per what is cookie saved. If one program on my Linux server connects using tcp fast open, does other program that connects to same server uses previous ones cookie for fast open? Or only sockets from same program can use each other cookies? Answer Few years ago the
How can I find the bridge device name for my tap adapter in C?
On Linux, using C, how can I find the find the name of the bridge device my ethernet interface is attached to? Is there a sequence of ioctl() calls I need to make to find the master bridge device? My C program knows the device name of my TAP adapter from a configuration file (in this case, tap0). Ultimately, I