Comments from Sim390 source file iucv.c (Process an IUCV (B2F0) instruction): IUCV is an S-type instruction: B2F0BDDD. R0 = IUCV function code. The logical address obtained from BDDD (base register and displacement) is actually treated as an ESA/390 real address: the address of the 40-byte parameter list (for IUCV function codes that use a parameter list). The param list must be on an 8-byte boundary, and must be entirely fetchable and storable in ESA/390 memory. Sim390 adds the requirement that the param list addr be x'100' or more. The IUCV instruction sets the Condition Code (mc.cc) if it does not cause a PI exception. Overview of IUCV and TCP/IP support: The IUCV and TCP/IP support in Sim390 is provided mainly to allow MUSIC's TCP/IP utilities (FTP, FTPD, INETD, HTTPD, etc.) to work as they do under VM. Under VM, MUSIC uses VM's IUCV (Inter-User Communications Vehicle) to talk to the TCPIP virtual machine. A MUSIC application program can establish an IUCV path to TCPIP, by which it can send socket requests (corresponding to the standard C socket routines) to TCPIP and receive data back. The TCPIP virtual machine is the one that communicates with the actual TCP/IP stack of VM. The major IUCV requests (done via B2F0 instructions) used are Declare Buffer, Connect, Send, and Sever. Connect is used by MUSIC to establish an IUCV path to TCPIP. After issuing a Connect request, MUSIC receives an IUCV Connection Complete external interrupt, indicating that the path is established. Then a socket routine call by the MUSIC application prog is implemented by an IUCV Send, usually with an answer buffer specified. The TCPIP virtual machine receives the IUCV send, does the real socket routine call, and passes back data (e.g. results of a socket read) to MUSIC via the answer buffer. The IUCV Send request (a B2F0 instruction) is done in Problem state by the routines in $tcp:sockets.s (see references below). This causes an Operation Exception (P.I. 1), which is trapped by the nucleus module IUCV ($sys:iucv.s), which interprets and issues the real B2F0 instruction in Supervisor state. The IUCV Send data format for each of the socket routines is documented in the VM TCP/IP Programmers Reference (see below). The TCPIP virtual machine receives the IUCV 2-way message from MUSIC, does the socket request, and does an IUCV Reply. This causes MUSIC to receive an IUCV Message Complete external interrupt, indicating that its answer buffer has been filled in. In the Sim390 emulator, the role of the TCPIP virtual machine is played by Sim390, which also handles the subset of IUCV requests that are needed. Sim390 calls Windows Socket routines to do the socket operation requested by the IUCV Send from the ESA/390 application prog (normally MUSIC). The ESA/390 application prog initiates the request via an IUCV Send, and Sim390 responds via an IUCV Message Complete external interrupt when it is done. Some details about the socket operations: - In some cases the operation is completed within the IUCV instruction. - In other cases (e.g. an application select(), or an application connect() recv() etc. on an application blocking-mode socket), the operation does not finish within the IUCV instruction, and the IUCV Message Complete external interrupt does not occur until later, sometimes much later. Sim390 works on it periodically during the instruction loop; see simcpu.c and pcselect.c. The status of the operation in progress is maintained in the socket table. When an operation accesses ESA/390 memory (always using real addresses), it is important to use the same addr mode (24 or 31-bit) and PSW key (mc.pswkey) as in the original IUCV instruction. See details in pcselect.c. IUCV/TCPIP uses the rmemacc() routine in most cases to fetch and store memory; see memacc.c; within the IUCV instruction, memaccess() can be used, with the options arg set for real address. - The Windows sockets are always in nonblocking mode. The ESA/390 application prog (MUSIC) can have several IUCV paths open at the same time, and each path can have several sockets associated with it. The socket numbering within each path is independent of other paths. For example, MUSIC can have path 1 with sockets 0 and 1, and path 2 with sockets 0, 1, and 2, for a total of 5 separate sockets. Normally a path in MUSIC is associated with a specific MUSIC TCB (Task Control Block), i.e. with a specific MUSIC application program task. Sim390 keeps track of the paths and sockets (with their corresponding Windows SOCKET handles) by its socket table. References: - Most IBM manuals are available online at www.ibm.com - IBM manual: VM/ESA CP Programming Services (SC24-5435 or equivalent), Part 2: Inter-User Communications Vehicle (IUCV). This describes the general IUCV supported by VM, and the details of the various IUCV requests and external interrupts. - IBM manual: IBM TCP/IP for VM: Programmer's Reference, Ver 2 Rel 4 (SC31-6084-03 or equivalent), Chap 5: IUCV Sockets. This describes the interface for communicating with the TCPIP virtual machine, via IUCV, in order to do socket calls from a virtual machine. This is the interface MUSIC uses. Also, Chap 2 describes the C socket functions that VM uses (the ones used by MUSIC are similar). - Microsoft documentation: Windows Sockets Version 2 API (in Platform SDK). - Book: Network Programming for MS Windows, by Anthony Jones and Jim Ohlund. 1999. MS Press. ISBN 0735605602. - Book: Unix Network Programming, by W. Richard Stevens. 1990. Prentice Hall. ISBN 0139498761. An excellent basic textbook on sockets from the Unix point of view.