<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Network Socket Notes</title>
	<atom:link href="http://ztkfg.com/2020/01/network-socket-notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://ztkfg.com/2020/01/network-socket-notes/</link>
	<description>198.211.113.164 // 6326 273B 61A7 00AF 4CD9 5A7B 8C6C AB19 24A6 4DEC</description>
	<pubDate>Thu, 16 Apr 2026 10:12:25 +0000</pubDate>
	<generator>http://polimedia.us</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jacob Welsh</title>
		<link>http://ztkfg.com/2020/01/network-socket-notes/#comment-191</link>
		<dc:creator>Jacob Welsh</dc:creator>
		<pubDate>Sat, 01 Feb 2020 03:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://ztkfg.com/?p=412#comment-191</guid>
		<description>This is traditionally called the BSD sockets API due to its origin. Looks like the guide gave a decent overview; your next step would be the man pages now that you know where to look and the general terminology.

&#62; The parameters given to socket determine whether the socket will use the tcp or udp as well as whether it will be used for network or local communication.

Picture a 2x2 grid. On one axis is the domain: inet or unix. On the other, the type: stream or datagram. There are some more obscure options, but for those named, all combinations are valid. Thus TCP and UDP provide the "wire protocol" implementation for the stream and datagram abstractions in the inet domain; while the same split exists for the unix domain, just without externally visible protocols. Unix-domain sockets are always local, though as you noted inet sockets can be local too.

&#62; Just like bind, connect tells the kernel to tie the given socket to an (ip address, port) pair. This pair is used as the return address for messages sent to the remote socket. The kernel picks a random available port for this purpose.

At first I thought you were talking about the destination address+port, as that's primarily what connect does. The source address+port auto-assignment happens if the socket isn't already bound (and note that it's not guaranteed to be all that random). In the case of tcp it indeed starts the process of establishing the connection, but can also be used on datagram sockets, eg. to enable use of send/recv rather than sendto/recvfrom. listen and accept however don't apply to datagram sockets.

To implement a typical server supporting concurrent clients, you either use multiple threads or processes, or else set the sockets to nonblocking and implement an event loop using poll or select.

A final call that belongs in this set is shutdown. You can do with just close in many cases, but shutdown allows closing one direction first, or forcibly closing when other processes sharing the socket may still have it open.</description>
		<content:encoded><![CDATA[<p>This is traditionally called the BSD sockets API due to its origin. Looks like the guide gave a decent overview; your next step would be the man pages now that you know where to look and the general terminology.</p>
<p>&gt; The parameters given to socket determine whether the socket will use the tcp or udp as well as whether it will be used for network or local communication.</p>
<p>Picture a 2x2 grid. On one axis is the domain: inet or unix. On the other, the type: stream or datagram. There are some more obscure options, but for those named, all combinations are valid. Thus TCP and UDP provide the "wire protocol" implementation for the stream and datagram abstractions in the inet domain; while the same split exists for the unix domain, just without externally visible protocols. Unix-domain sockets are always local, though as you noted inet sockets can be local too.</p>
<p>&gt; Just like bind, connect tells the kernel to tie the given socket to an (ip address, port) pair. This pair is used as the return address for messages sent to the remote socket. The kernel picks a random available port for this purpose.</p>
<p>At first I thought you were talking about the destination address+port, as that's primarily what connect does. The source address+port auto-assignment happens if the socket isn't already bound (and note that it's not guaranteed to be all that random). In the case of tcp it indeed starts the process of establishing the connection, but can also be used on datagram sockets, eg. to enable use of send/recv rather than sendto/recvfrom. listen and accept however don't apply to datagram sockets.</p>
<p>To implement a typical server supporting concurrent clients, you either use multiple threads or processes, or else set the sockets to nonblocking and implement an event loop using poll or select.</p>
<p>A final call that belongs in this set is shutdown. You can do with just close in many cases, but shutdown allows closing one direction first, or forcibly closing when other processes sharing the socket may still have it open.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
