<?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=Socket</id>
	<title>Socket - 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=Socket"/>
	<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Socket&amp;action=history"/>
	<updated>2026-05-03T18:16:53Z</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=Socket&amp;diff=63&amp;oldid=prev</id>
		<title>Winston at 21:07, 28 March 2008</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Socket&amp;diff=63&amp;oldid=prev"/>
		<updated>2008-03-28T21:07:59Z</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 22:07, 28 March 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-l28&quot;&gt;Line 28:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 28:&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;br/&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;br/&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;  ld c, SOCK_STREAM       ; A reliable stream - TCP&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;  ld c, SOCK_STREAM       ; A reliable stream - TCP&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ld hl, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0x3E00 &lt;/del&gt;          ; Call table for socket()&lt;/div&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;  ld hl, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;SOCKET &lt;/ins&gt;          ; Call table for socket() &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;- 0x3E00&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;  call HLCALL             ; Trigger ROM page in&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;  call HLCALL             ; Trigger ROM page in&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;  bit 7, a                ; Check for a negative return code (MSB set)&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;  bit 7, a                ; Check for a negative return code (MSB set)&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=Socket&amp;diff=62&amp;oldid=prev</id>
		<title>Winston: Experiment with documentation format for function calls</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Socket&amp;diff=62&amp;oldid=prev"/>
		<updated>2008-03-28T21:05:48Z</updated>

		<summary type="html">&lt;p&gt;Experiment with documentation format for function calls&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''socket (HLCALL 0x3E00) ''' - Create an end point for communication.&lt;br /&gt;
&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
&lt;br /&gt;
''Assembly language''&lt;br /&gt;
 &lt;br /&gt;
    ld c, socket_type&lt;br /&gt;
    ld hl, 0x3E00&lt;br /&gt;
    call HLCALL&lt;br /&gt;
&lt;br /&gt;
''C''&lt;br /&gt;
&lt;br /&gt;
 int socket(int domain, int type, int protocol);&lt;br /&gt;
&lt;br /&gt;
The '''socket''' function opens an end point for communication, and returns a file descriptor on success. Only AF_INET sockets are supported. In the C interface, the domain and protocol parameters are provided for compatibility with the BSD socket library and are ignored. The protocol parameter should be set to zero; it is very possible that the protocol parameter will be used in a later release of the library.&lt;br /&gt;
&lt;br /&gt;
The socket function allocates the resources required to communicate. It allocates a descriptor ('socket handle'), and associates this with the appropriate hardware registers.&lt;br /&gt;
&lt;br /&gt;
== Return value ==&lt;br /&gt;
&lt;br /&gt;
On success, a file descriptor for the new socket is returned in the A register (asm interface) or as the return code (C interface). On error, the asm interface returns the error code in A, and the C interface returns -1 and sets errno to the error number.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
The following example shows how to open a socket that will be used for a TCP connection (either one that listens for incoming connections, or will be used to connect to a remote host). The socket() function just opens the socket - it doesn't decide whether it's to be used for a server or client connection. To open a UDP connection, the type parameter should be set to SOCK_DGRAM.&lt;br /&gt;
&lt;br /&gt;
Assembly language:&lt;br /&gt;
&lt;br /&gt;
 ld c, SOCK_STREAM       ; A reliable stream - TCP&lt;br /&gt;
 ld hl, 0x3E00           ; Call table for socket()&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;
 &lt;br /&gt;
 ; at this point, A contains the file descriptor (aka socket handle)&lt;br /&gt;
&lt;br /&gt;
C:&lt;br /&gt;
&lt;br /&gt;
 int sock;&lt;br /&gt;
 sock=socket(AF_INET, SOCK_STREAM, 0);&lt;br /&gt;
 if(sock &amp;gt; 0)&lt;br /&gt;
 {&lt;br /&gt;
    /* socket opened successfully, do something */&lt;br /&gt;
 }&lt;br /&gt;
 else&lt;br /&gt;
 {&lt;br /&gt;
    /* handle the error */&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Spectranet]]&lt;/div&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
</feed>