how to bind raw socket to specific interface

const char *opt; opt = “eth0”; const len = strnlen(opt, IFNAMSIZ); if (len == IFNAMSIZ) { fprintf(stderr, “Too long iface name”); return 1; } setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, opt, len); First line: set up your variable Second line: tell the program which interface to bind to Lines 3-5: get length of interface name and check if … Read more

A call to SSPI failed, see inner exception – The Local Security Authority cannot be contacted

This means the other side is using another version of TLS and you are using an older version. Set up security attribute to TLS12 before making the connection. This is a widely known problem, as many providers start using TLS12 (e.g. paypal,amazon and so on). ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Application control of TCP retransmission on Linux

Looks like this was added in Kernel 2.6.37. Commit diff from kernel Git and Excerpt from change log below; commit dca43c75e7e545694a9dd6288553f55c53e2a3a3 Author: Jerry Chu Date: Fri Aug 27 19:13:28 2010 +0000 tcp: Add TCP_USER_TIMEOUT socket option. This patch provides a “user timeout” support as described in RFC793. The socket option is also needed for the … Read more

“zero copy networking” vs “kernel bypass”?

What is the difference between “zero-copy networking” and “kernel bypass”? Are they two phrases meaning the same thing, or different? Is kernel bypass a technique used within “zero copy networking” and this is the relationship? TL;DR – They are different concepts, but it is quite likely that zero copy is supported within kernel bypass API/framework. … Read more

How do you throttle the bandwidth of a socket connection in C?

The problem with sleeping a constant amount of 1 second after each transfer is that you will have choppy network performance. Let BandwidthMaxThreshold be the desired bandwidth threshold. Let TransferRate be the current transfer rate of the connection. Then… If you detect your TransferRate > BandwidthMaxThreshold then you do a SleepTime = 1 + SleepTime … Read more

java.net.URLEncoder.encode(String) is deprecated, what should I use instead?

Use the other encode method in URLEncoder: URLEncoder.encode(String, String) The first parameter is the text to encode; the second is the name of the character encoding to use (e.g., UTF-8). For example: System.out.println( URLEncoder.encode( “urlParameterString”, java.nio.charset.StandardCharsets.UTF_8.toString() ) );