[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1742690447110333.jpg (488 KB, 2000x1502)
488 KB
488 KB JPG
previous: >>108110059

#define __NR_socket                41

https://man7.org/linux/man-pages/man2/socket.2.html

this honestly ought to be one of the most popular threads i end up making in this series. sockets are a fascinating and frighteningly complex tool. they can do everything. i mean, my god. just look at this manpage. terrifying!
with that being said, i haven't had much occasion to use them myself. i try to avoid networking, generally, and there are often better choices if you need IPC for something.
have you ever used sockets before? if so, how? did you end up enjoying them, or would you have preferred a different tool?

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
>>108120258
I'd use her socket.
>>
Yeah, I use sockets for IPC all the time.
>>
I guess that explains why you can do networking in basically any language. Why is it that so many servers are written in Javascript and Python then if you can choose any language?
>>
>>108121121
Because people like writing programs in JavaScript or Python or sometimes even Ruby
>>
>>108121330
I can't speak for Ruby, but I'm very skeptical that anyone likes programming in JS or Python.
>>
>>108121387
Python is fucking great
>>
>>108121402
Python is fucking dog shit though
>>
>>108121442
I will stop using it now, thank you.
>>
you can use unix domain sockets to give file descriptors to another socket. it's a nice way to make your web programs a little bit more secure
>>
>>108121840
yeah, imo sending over the file descriptors is one of the things that's most useful
>>
>>108120258
GYAAAAAAAAAAAAAAAAAAAAAAAATTTTTT
>>
I like SO_PEERCRED. You can get the process id, user id and group id of the remote peer (when using a unix socket domain)
>>
>>108120258
Why do you have to post this kind of pic?
>>
>>108123304
erotic things stimulate the mind
>>
>>108120258
I would have said something really insightful, but not with this picture. Fuck you, OP.
>>
>>108123304
it has socks in it. plus i think dolls are cute. what exactly is wrong with it? it's barely even lewd, if at all
>>
bampu
>>
Where's your critique, OP? Or are you actually not aware how fucking retarded socket() in specific and kernel I/O in general is?
>>
>>108124741
well, it's a couple things. i am sick, so i'm low energy and not really feeling up for doing much. also, these threads haven't been getting a lot of engagement recently, so i wasn't sure how much i wanted to write up in the OP about it. especially since it's already such a complicated syscall, it felt like half-assing it would be worse than just not saying much at all and just trying to solicit responses from other posters. finally, as i briefly mentioned in the OP, i just don't ever really use it. 99% of the time (at least in my use cases), there have been better options for IPC, so i just use those instead
>>
gosh.... so few posts
>>
>>108126056
I'm sorry anon... I have an exam soon and haven't used sockets pretty much since networking classes
>>
File: 1768682444961381.gif (328 KB, 200x200)
328 KB
328 KB GIF
>>108120258
>doll feet
>>
>>108126306
i will forgive u just this once...
>>108126372
for me, i really like the joints for some reason
the ball and... socket joints
hehe
>>
>>108120258
The socket API was and continues to be, beyond the shadow of a doubt, one of the single worst API designs in the history of the entire C programming language. Sockets are not files and should not be treated as such.
>>
>>108120258
Only faggots play with dolls.
>>
>>108126502
you're not gonna believe this, but...
>>
>>108126489
>Sockets are not files and should not be treated as such.
I don't mind. In fact, if we treated files a little bit more like sockets, we wouldn't have the nonsense nightmare that is blocking open(). Just imagine:
>reserve a bunch of file descriptor numbers in the process' handle table
>explicitly connect file descriptor number to file name during open call (can be several at once) and add them all to an epoll descriptor
>you can now do other shit in your process while the kernel opens all the files in the background
>libaio and io_uring have just become slightly more useful
>>
>>108127124
based
>>
>>108120550
I know what you mean
(if you mean what I think you mean. Otherwise no, I have no idea what you mean).
>>
>>108127543
hehe
>>
really not much interest in sockets, huh?
>>
>>108120258
>have you ever used sockets before? if so, how? did you end up enjoying them, or would you have preferred a different tool?
I've written an HTTP server from scratch on Linux and Windows. There's no alternative.
>>
>>108127124
>we wouldn't have the nonsense nightmare that is blocking open()
Did you know Windows NT has had overlapped IO ever since 3.1?
>>
>>108120258
Sockets are AWESOME

>>108121121
I have used sockets in C and its kinda tedious. For example, both requests and responses are sent/delivered as void*, which you can imagine is frustrating because you have to manage allocations for each element yourself. Python you can imagine does things more simply
>>
>>108130675
You are conflating two different things here: open()/NtCreateFile(), and all the other file I/O operations. open()/NtCreateFile() still block the thread, and the only thing that you can control is which thread is being blocked (also see openat2's RESOLVE_CACHED flag, which was introduced after io_uring was accepted).

That being said:
>completion ports: absolute fucking clusterfuck, single submissions only, meaning loads of mode switches
>ReadFileScatter/WriteFileGather: multiple submissions, but all still limited to a single file handle, still limited to all reads or all writes

libaio was better, at least in terms of interface.
>>
>>108130711
>because you have to manage allocations for each element yourself
Reserve-high/commit-low.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.