<?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=Poll</id>
	<title>Poll - 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=Poll"/>
	<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Poll&amp;action=history"/>
	<updated>2026-05-07T23:45:00Z</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=Poll&amp;diff=160&amp;oldid=prev</id>
		<title>Winston: New page: '''poll - HLCALL 0x3E1E''' - poll an array of sockets  '''pollfd, poll_fd - HLCALL 0x3E24''' - poll a single socket  '''pollall - HLCALL 0x3E21''' - poll all open sockets  == Synopsis ==  ...</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Poll&amp;diff=160&amp;oldid=prev"/>
		<updated>2008-08-25T18:55:02Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;poll - HLCALL 0x3E1E&amp;#039;&amp;#039;&amp;#039; - poll an array of sockets  &amp;#039;&amp;#039;&amp;#039;pollfd, poll_fd - HLCALL 0x3E24&amp;#039;&amp;#039;&amp;#039; - poll a single socket  &amp;#039;&amp;#039;&amp;#039;pollall - HLCALL 0x3E21&amp;#039;&amp;#039;&amp;#039; - poll all open sockets  == Synopsis ==  ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''poll - HLCALL 0x3E1E''' - poll an array of sockets&lt;br /&gt;
&lt;br /&gt;
'''pollfd, poll_fd - HLCALL 0x3E24''' - poll a single socket&lt;br /&gt;
&lt;br /&gt;
'''pollall - HLCALL 0x3E21''' - poll all open sockets&lt;br /&gt;
&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
&lt;br /&gt;
''Assembly language''&lt;br /&gt;
&lt;br /&gt;
''poll:''&lt;br /&gt;
     ld de, addr_socklist      ; pointer to a list of sockets to poll&lt;br /&gt;
     ld b, num_socks           ; number of sockets in the list&lt;br /&gt;
     ld hl, POLL&lt;br /&gt;
     call HLCALL               ; returns socket in A, flags in B&lt;br /&gt;
&lt;br /&gt;
''pollfd:''&lt;br /&gt;
     ld a, (v_sockfd)          ; socket file descriptor&lt;br /&gt;
     ld hl, POLLFD&lt;br /&gt;
     call HLCALL               ; zero flag is set if sockfd is not ready. Flags returned in C&lt;br /&gt;
&lt;br /&gt;
''pollall:''&lt;br /&gt;
     ld hl, POLLALL&lt;br /&gt;
     call HLCALL               ; zero flag set if none ready, else A contains fd and C contains flags&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;sockpoll.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
     char poll_fd(int sockfd);&lt;br /&gt;
     int pollall(struct pollfd *p);&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
'''poll, pollall and pollfd''' check the state of sockets, and immediately return information on the socket's state. The '''poll''' routine (TO DO: C library POSIX compatible implementation) checks the sockets listed in an array. The '''pollfd''' (asm) and poll_fd (C) routines report the state of an individual socket. The '''pollall''' function polls all open sockets, reporting the status of the first socket found to have significant status.&lt;br /&gt;
&lt;br /&gt;
The '''pollall''' routine takes a struct pollfd pointer as its parameter, and fills the ''revents'' member of the structure with the status flags, and returns the socket file descriptor as its return code. The '''pollfd''' (C: poll_fd) function returns a single byte containing a bit field that is defined in the same manner as the revents field of the struct pollfd.&lt;br /&gt;
&lt;br /&gt;
The events/revents bit field is defined as follows, and is identical for the asm and C functions:&lt;br /&gt;
&lt;br /&gt;
 #define POLLCON     1        /* a remote host connected to the listening socket (not POSIX) */&lt;br /&gt;
 #define POLLHUP     2        /* the remote host closed the connection */&lt;br /&gt;
 #define POLLIN      4        /* data is ready to be received */&lt;br /&gt;
 #define POLLNVAL    128      /* error occurred during polling */&lt;br /&gt;
&lt;br /&gt;
== Return values ==&lt;br /&gt;
&lt;br /&gt;
The assembly language interface returns with the zero flag set for all of the poll functions if no socket that was polled had any significant status. When a socket has significant status, poll and pollall return the socket descriptor in A, and reset the zero flag. The poll routine returns the flags in B. For pollall and pollfd, the flags are returned in C.&lt;br /&gt;
&lt;br /&gt;
For the C functions, pollall returns the socket descriptor, and fills the passed pollfd structure. The poll_fd function returns the flags if the socket polled has significant status, otherwise, it returns 0.&lt;br /&gt;
&lt;br /&gt;
[[Category:Spectranet]]&lt;/div&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
</feed>