In article <9ac4de$24k$1 at merck.com>, Paul Nicolay <paIulHATE_nicSPAMolay at merck.com> wrote: >I'll try to answer your questions... > >1. The AS/400 is indeed a reasonable platform (and scales way beyond what >others offer) to have network servers running, the question is however is >Python the best environment to write them in (which I doubt seriously) ? I suppose it depends on the particular network server. (Unless you mean "Python on the AS/400", in which case I share your serious doubts.) So how do you do event-driven I/O on OS/400? Unix assigns a small process-local integer to each I/O stream called a "file descriptor"; there's a system call called 'select' to which you pass three bitvectors: one with bits set at indices of file descriptors you want to be notified of readability on, one with bits set at indices of file descriptors you want to be notified of writability on, and wone with bits set at indices of file descriptors you want to be notified of "exceptional conditions" on. You also pass a timeout. When the timeout expires, or when one or more of the events you've requested notification of happens, select() returns, having cleared all the bits in these bitvectors that correspond to events that didn't happen --- leaving only the bits set that correspond to events that did happen. So if you're interested in incoming data on fd's 0, 1, and 2, you set bits 0, 1, and 2 in the 'readfds' bitvector and leave the 'writefds' and 'exceptfds' bitvectors all-zero, then call select(). select() sleeps until there is incoming data on at least one of these fd's, or for as long as your timeout value specified, if you specified one. If there is incoming data pending on fd 1 only, then when select() returns, only bit 1 will be set in 'readfds'. This is reasonably efficient for small numbers of network connections; it starts to peter out around a thousand or so, because you have to scan the entire bitvector to find the two or three bits that are set. This lets you write your code in a single-threaded fashion with "event handlers" that handle incoming data (or the opportunity to write outgoing data) on particular network connections; so you don't have to context-switch between threads when switching between handling data on different connections. What's the OS/400 way to do similar things? >4. You can get accounts for less, but they probably don't offer you Python >for testing purposes. Maybe the best approach is again to contact the guys >from the port. I could install Python on them, though, couldn't I? Or is installing software an unusual ability to have in OS/400? -- <kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/> Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4