<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://spectrum.alioth.net/doc/index.php?action=history&amp;feed=atom&amp;title=Bind</id>
	<title>Bind - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://spectrum.alioth.net/doc/index.php?action=history&amp;feed=atom&amp;title=Bind"/>
	<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Bind&amp;action=history"/>
	<updated>2026-05-16T15:30:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=70&amp;oldid=prev</id>
		<title>Winston at 22:38, 5 April 2008</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=70&amp;oldid=prev"/>
		<updated>2008-04-05T22:38:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:38, 5 April 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l55&quot;&gt;Line 55:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 55:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     addr.sin_family = AF_INET;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     addr.sin_family = AF_INET;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    addr.sin_addr.s_addr = htonl(INADDR_ANY); /* provided for compatibility */&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     addr.sin_port = htons(2000); /* htons is a no-op, but a macro is provided for compatibility */&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     addr.sin_port = htons(2000); /* htons is a no-op, but a macro is provided for compatibility */&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     if(bind(sockfd, &amp;amp;addr, sizeof(addr)) &amp;lt; 0)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     if(bind(sockfd, &amp;amp;addr, sizeof(addr)) &amp;lt; 0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
	<entry>
		<id>https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=69&amp;oldid=prev</id>
		<title>Winston at 22:36, 5 April 2008</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=69&amp;oldid=prev"/>
		<updated>2008-04-05T22:36:25Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:36, 5 April 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l61&quot;&gt;Line 61:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 61:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Spectranet]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
	<entry>
		<id>https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=68&amp;oldid=prev</id>
		<title>Winston: New page: '''bind - HLCALL 0x3E0C''' - Bind a local address to a socket.  == Synopsis ==  ''Assembly language''   ld a, (socket_fd)   ; The socket handle, as returned by socket  ld de, 2000     ...</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Bind&amp;diff=68&amp;oldid=prev"/>
		<updated>2008-04-05T22:34:21Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;bind - HLCALL 0x3E0C&amp;#039;&amp;#039;&amp;#039; - Bind a local address to a socket.  == Synopsis ==  &amp;#039;&amp;#039;Assembly language&amp;#039;&amp;#039;   ld a, (socket_fd)   ; The socket handle, as returned by &lt;a href=&quot;/doc/index.php/Socket&quot; title=&quot;Socket&quot;&gt;socket&lt;/a&gt;  ld de, 2000     ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''bind - HLCALL 0x3E0C''' - Bind a local address to a socket.&lt;br /&gt;
&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
&lt;br /&gt;
''Assembly language''&lt;br /&gt;
&lt;br /&gt;
 ld a, (socket_fd)   ; The socket handle, as returned by [[socket]]&lt;br /&gt;
 ld de, 2000         ; Port number&lt;br /&gt;
 ld hl, BIND         ; Jump table entry point - 0x3E0C&lt;br /&gt;
 call HLCALL&lt;br /&gt;
 jr c, .handle_error ; On error, carry flag is set&lt;br /&gt;
&lt;br /&gt;
''C''&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);&lt;br /&gt;
&lt;br /&gt;
bind() gives the socket sockfd the local address my_addr. In this implementation, only the port address is used for the local address, and other parameters in the sockaddr structure are currently ignored. Fields are provided for compatibility.&lt;br /&gt;
&lt;br /&gt;
It is normally necessary to assign a local address before a SOCK_STREAM can accept incoming connections. The port number passed to bind is the port that will be listened on when the [[listen]] call is made.&lt;br /&gt;
&lt;br /&gt;
== Return value ==&lt;br /&gt;
&lt;br /&gt;
On success, the assembly language interface returns with the carry flag cleared. On error, the accumulator contains the error number and the carry flag is set.&lt;br /&gt;
&lt;br /&gt;
On success, the C interface returns zero. On error, -1 is returned, and errno is set to the error number.&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
&lt;br /&gt;
The port number is the only local address that is used, since the hardware only supports a single internet protocol address; in the C interface, all other fields in the sockaddr structure are ignored. C programmers should still avoid invalid values in case these values are used in the future. It is acceptable to zero out unused values.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
''Assembly language''&lt;br /&gt;
 ld c, SOCK_STREAM       ; A reliable stream - TCP&lt;br /&gt;
 ld hl, SOCKET           ; Call table for socket() - 0x3E00&lt;br /&gt;
 call HLCALL             ; Trigger ROM page in&lt;br /&gt;
 bit 7, a                ; Check for a negative return code (MSB set)&lt;br /&gt;
 jr nz, .handle_error    ; failed to allocate a socket if the return code &amp;lt; 0&lt;br /&gt;
 ld (sock_fd), a         ; save socket handle&lt;br /&gt;
 ld de, 2000             ; Bind to port 2000&lt;br /&gt;
 ld hl, BIND&lt;br /&gt;
 call HLCALL&lt;br /&gt;
 jr c, .handle_error&lt;br /&gt;
 &lt;br /&gt;
 ; local address is now our current IP address, port 2000.&lt;br /&gt;
&lt;br /&gt;
''C''&lt;br /&gt;
 int sockfd;&lt;br /&gt;
 struct sockaddr_in addr;&lt;br /&gt;
 sock=socket(AF_INET, SOCK_STREAM, 0);&lt;br /&gt;
 if(sock &amp;gt; 0)&lt;br /&gt;
 {&lt;br /&gt;
    addr.sin_family = AF_INET;&lt;br /&gt;
    addr.sin_port = htons(2000); /* htons is a no-op, but a macro is provided for compatibility */&lt;br /&gt;
    if(bind(sockfd, &amp;amp;addr, sizeof(addr)) &amp;lt; 0)&lt;br /&gt;
    {&lt;br /&gt;
       handle_error(&amp;quot;bind&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
</feed>