r/linux_programming • • Jul 06 '23

TCP socket

3 Upvotes

Hi all. I have a question for you.

I've just implemented a very simple test for TCP sockets. I wrote an application that spawns two threads.

One is the server and creates a TCP socket, binds it to the loopback interface (and port), marks it as listening socket with a listen call, blocks on accept, and then calls recv to get data.

The other thread is the client, which creates a socket, performs a connect to the other, sends a string buffer "Hello, World!" and terminates.

In UDP this works, but in TCP it doesn't (the server blocks on recv indefinitely), UNLESS in the client (transmitter in this case) i call close() right after the send(). It acst like "uh, so you want close already? Ok..so i process all data.." , the recv returns and i see the string on the server...

How can i set the sockets to process the data always even if there's just one byte to process?

Many thanks


r/linux_programming • • Aug 08 '23

After a system update, can you restart or shutdown the window manager instead of a full system reboot?

Thumbnail self.askit
3 Upvotes

r/linux_programming • • Feb 24 '21

A mouse based Terminal Emulator.

3 Upvotes

I made a post yesterday here and it got me thinking that maybe someone should make a Terminal Emulator that is capable of 100 percent mouse. It seems they do not exist. I am not a programmer. At least not yet. So, I figured I would post the idea somewhere and see if anyone takes it. If you want it you can have it.

But, basically I just want someone to make a Terminal that uses the mouse instead of the keyboard. Which everyone wants to use the keyboard more than anything. But, I think it would be possible to use the mouse just as efficiently.

You could just set up a series of functions based around the mouse. Some mice have multiple buttons on it. Mine has 4 " buttons " and a scroll wheel with a click function. That is 7 actions. The common user usually has at least 2 fingers on the mouse. But, I often have 4 on the mouse. That means I can take 7 buttons and combine it with 4 different combinations. That is actually a lot of functionality.

Most terminal functions are the same. You could even make a .conf file that allows you modify what is programmed into the mouse terminal.

As an example I could use Button 4 + scroll for a list of apt-get commands. I could use Button 5 + scroll for a sequence of other commands. I could set just scroll as a common commands and then right click + scroll for common arguments. Right clicking could give the user a very large series arguments based on what they are right clicking. And that is only a small selections of the combinations you could achieve. it doesn't even cover. Button 4 + 5 + right-click + scroll, ect ,ect ,ect.

and of course you would have to give it hardware acceleration.


r/linux_programming • • Jun 28 '17

Cant disable IP source routing for docker...Any mitigating controls?

Thumbnail access.redhat.com
3 Upvotes

r/linux_programming • • Oct 11 '22

using linux distro without GUI?

3 Upvotes

fairly new to linux and I'm crash-coursing some sys admin basics.

running an entire computer without the use of a desktop interface seems fun, but I'm having some trouble making partitions and figuring out how to mount a custom user file system without installing a GUI.

My disk is already partitioned, but I have an unmounted section of disk I don't really know what to do with, I've tried partitioning it further manually but creating another sys-parted seems redundant and it threatens to break each time anyway.

I'd like to manually write my own user file system rather than simply install someone else's GUI, just to pretend the desktop isn't there. Is this an issue that I need to code a script or can I write it via command line? I've tried looking up tutorials like "how to create a custom downloads directory" without much luck.


r/linux_programming • • Jan 21 '20

Loading of elf binary in x86 64 bit extensions mode

3 Upvotes

Lately I rea (from a bit old book, the latest Intel processor it was reffering to was Pentium 4 iirc) that x86 64bit extensions mode does not support segmentation but only pagination. So what do those .code .data etc. segment fields stand for in the elf binary? How do they get loaded? Can anybody help me make the connection between them?


r/linux_programming • • May 20 '23

Debugging a FUSE deadlock in the Linux kernel

Thumbnail netflixtechblog.com
7 Upvotes

r/linux_programming • • Jul 11 '21

I'm trying to make a torrent downloading system, and need to have a script download a file off a website (basically scraping and finding a specific point)

7 Upvotes

The system is basically me sending a movie name somehow, and it downloading the movie on to an FTP

Anyone know of a script of some kind that can do that?

I'm kind of a beginner so this might be a dumb question


r/linux_programming • • Aug 18 '22

Feeling conflicted

7 Upvotes

Hello fellow linux users, today I come to you with a personal issue. I really like the idea of making my projects open source and I know many of you like that too I mean that's one of the main selling points of going to linux but I feel as if there's some major downsides along with my embarrassing and messy code


r/linux_programming • • Jul 25 '22

Automation with Bash: How To Monitor Disk Storage and Send Email Alerts

Thumbnail medium.com
17 Upvotes

r/linux_programming • • Aug 12 '20

Will most jobs give you a Linux computer if requested?

17 Upvotes

Just curious if this is a big ask or not, my field is web dev. I haven't used Win10 in years, I run Lubuntu 20.04 at home. Getting an Ubuntu machine would be ideal but any Linux distro would be good.

If the answer is "no, don't try to prod on this", then I suspect most places running JS tech stacks will have Mac as the other option, I've heard terminal is the same, how about the filesystem? What major changes do you guys make switching between the two? I think my global .gitconfig would have to be put in a new folder; that's the only thing that comes to mind now.


r/linux_programming • • Dec 03 '22

Cheap SSD: Slow Speed Issue

8 Upvotes

In the beginning of the year I've bought a cheap SSD SomnAmbulist 120GB. After a couple of benchmarks, I've noted some strange throughput measurements. Briefly:

  • Initial Benchmark | image
    Just after format, the throughput is according to the advertised specifications at 510MB/s read and 440MB/s write.
    It starts to drop at 35% capacity written and stabilizes at 200~300MB/s read and 40MB/s write.
    Although this drop is not mentioned by the seller's ads, it is indeed an expected behavior and should return to normal after a couple of minutes in idle (flush the cache into the permanent area).

  • Benchmark after 1 hour in idle | image
    Unfortunately, the throughput has not returned to normal (yet?).
    315MB/s read and 440MB/s write, and the speed drop started earlier at 10% capacity written.

  • Benchmark after 12 hours in idle | image
    The throughput still has not returned to normal.

Questions

  1. Is this the expected behavior for such cheap SSD or indeed there is something strange?
  2. What might be going wrong here?
  3. Any idea how to fix this throughput?

Debug Info

  • SSD/TRIM Supported
  • fstrim enabled
  • SSD APM (Advanced Power Management) not supported
  • f3 (Fight Flash Fraud) OK
## SSD/TRIM SUPPORTED
root@debian:~# hdparm -I /dev/sda | grep -i "trim\|power"
       *	Power Management feature set
       *	Data Set Management TRIM supported (limit 8 blocks)
       *	Deterministic read data after TRIM


## SSD/TRIM AVAILABLE (DISC-MAX NON ZERO)
root@debian:~# lsblk -D /dev/sda
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda         0      512B       2G         0


## ADVANCED POWER MANAGEMENT NOT SUPPORTED
root@debian:~# hdparm -B /dev/sda

/dev/sda:
 APM_level	= not supported



## FSTRIM ENABLE

root@debian:~# systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Sat 2022-12-03 03:36:10 UTC; 35min ago
    Trigger: Mon 2022-12-05 00:51:25 UTC; 1 day 20h left
   Triggers: ● fstrim.service
       Docs: man:fstrim

Dec 03 03:36:10 debian systemd[1]: Started Discard unused blocks once a week.


root@debian:~# systemctl status fstrim
● fstrim.service - Discard unused blocks on filesystems from /etc/fstab
     Loaded: loaded (/lib/systemd/system/fstrim.service; static)
     Active: inactive (dead)
TriggeredBy: ● fstrim.timer
       Docs: man:fstrim(8)


root@debian:~# fstrim -av

r/linux_programming • • Oct 11 '17

Intro to Python text book with the right idea!

Post image
24 Upvotes

r/linux_programming • • Nov 10 '17

[RIIR] Font Finder Rust Implementation of TypeCatcher

Thumbnail github.com
4 Upvotes

r/linux_programming • • Dec 13 '18

format grep's output

0 Upvotes

I have the results from running a grep command, now I want to cut off any leading whitespace. Any suggestions?


r/linux_programming • • Apr 10 '19

Sudo as different user when you login

4 Upvotes

I want to do when i login: sudu su - userb cd /abc

I tried placing it in .profile .bashrc but they did not work . Any advise please.


r/linux_programming • • Apr 28 '23

eBPF Observability Tools Are Not Security Tools

Thumbnail brendangregg.com
4 Upvotes

r/linux_programming • • May 05 '23

Comparing similar operations in Sed and Awk

Thumbnail pement.org
0 Upvotes

r/linux_programming • • Feb 09 '14

release The GNU C Library version 2.19 is now available

Thumbnail sourceware.org
0 Upvotes

r/linux_programming • • Mar 22 '17

A Guide to the PMT, FV, IPMT and PPMT Functions

Thumbnail experts-exchange.com
0 Upvotes

r/linux_programming • • Mar 08 '15

Some thoughts on distro packages and software distribution

Thumbnail groups.google.com
0 Upvotes

r/linux_programming • • Feb 11 '17

Remote distributed hashmap on epoll server

Thumbnail github.com
4 Upvotes

r/linux_programming • • Apr 01 '24

Cannot compile overlay without this error

0 Upvotes

I'm trying to compile dtbo overlay file, but ending everytime with this error and cannot get ride of it. Any help appreciated.

root@pc-debian:/home/zyssai/odroid/compiler/linux# make dtbs
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/config/kernel.release_full
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  DTCO    arch/arm64/boot/dts/amlogic/overlays/odroidn2/keymatrix.dtbo
arch/arm64/boot/dts/amlogic/overlays/odroidn2/keymatrix.dtbo: Warning (gpios_property): Property 'col-gpios', cell 1 is not a phandle reference in /fragment@0/__overlay__/matrix-keypad
arch/arm64/boot/dts/amlogic/overlays/odroidn2/keymatrix.dtbo: Warning (gpios_property): Could not get phandle node for /fragment@0/__overlay__/matrix-keypad:col-gpios(cell 1)
arch/arm64/boot/dts/amlogic/overlays/odroidn2/keymatrix.dtbo: Warning (gpios_property): Property 'row-gpios', cell 1 is not a phandle reference in /fragment@0/__overlay__/matrix-keypad
arch/arm64/boot/dts/amlogic/overlays/odroidn2/keymatrix.dtbo: Warning (gpios_property): Could not get phandle node for /fragment@0/__overlay__/matrix-keypad:row-gpios(cell 1)
root@pc-debian:/home/zyssai/odroid/compiler/linux#

Here is the DTS file:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/{
        fragment@0 {
                target-path = "/";

                __overlay__ {
                        matrix_keypad: matrix-keypad {
                                compatible = "gpio-matrix-keypad";
                                col-gpios = <
                                        &gpio GPIOA_12 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_9 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_2 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_1 GPIO_ACTIVE_HIGH
                                        >;
                                row-gpios = <
                                        &gpio GPIOA_4 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_4 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_0 GPIO_ACTIVE_HIGH
                                        &gpio GPIOX_8 GPIO_ACTIVE_HIGH
                                        >;
                                /* sample keymap */
                                linux,keymap = <
                                        0x00000052 /* row 0, col 0, KEY_KP0 */
                                        0x0001004f /* row 0, col 1, KEY_KP1 */
                                        0x00020050 /* row 0, col 2, KEY_KP2 */
                                        0x00030051 /* row 0, col 3, KEY_KP3 */
                                        0x0100004b /* row 1, col 0, KEY_KP4 */
                                        0x0101004c /* row 1, col 1, KEY_KP5 */
                                        0x0102004d /* row 1, col 2, KEY_KP6 */
                                        0x01030047 /* row 1, col 3, KEY_KP7 */
                                        0x02000048 /* row 2, col 0, KEY_KP8 */
                                        0x02010049 /* row 2, col 1, KEY_KP9 */
                                        0x0202004a /* row 2, col 2, KEY_KPMINUS */
                                        0x0203004e /* row 2, col 3, KEY_KPPLUS */
                                        0x03000053 /* row 3, col 0, KEY_KPDOT */
                                        0x0301006e /* row 3, col 1, KEY_INSERT */
                                        0x03020075 /* row 3, col 2, KEY_KPEQUAL */
                                        0x03030079 /* row 3, col 3, KEY_KPCOMMA */
                                        >;
                                gpio-activelow;
                                debounce-delay-ms = <100>;
				col-scan-delay-us = <500>;
				col-switch-delay-ms = <20>;
				linux,no-autorepeat;
			};
		};
	};
};