Next Previous Up Top Contents Index

10.2 Utilities

start-sockets

Function

start-sockets () => ()

Applications must call this function before using any other function or variable from the Network library.
This function is necessary because the Win32 API library Winsock2, which the Network library calls to get native socket functionality, requires applications to call an initialization function before calling any Winsock2 API functions. The call to start-sockets calls this underlying Winsock2 function.
Note that you must not call start-sockets from a top-level form in any DLL project. The combination of this, and the restriction that you must call start-sockets before calling anything else, implies that no Network library function or variable can be called (directly or indirectly) from a top-level form in any DLL project. Instead, the DLL project should define a start function that calls start-sockets (directly or indirectly) or re-export start-sockets so that their clients can arrange to have it called from a top-level form in an appropriate EXE project.
Applications using the Network library must arrange for start-sockets to be called (directly or indirectly) before any other sockets API functions. A good place to do this is at the beginning of your start function (usually the main method). For example:
define method main () => ();
  start-sockets();
  let the-server = make(<TCP-server-socket>, port: 7);
  ...
end;

begin main(); end;

New start functions that call start-sockets and that are defined for DLL projects that use the Network library will inherit all of the restrictions described above for start-sockets.
Calling a Network library function before calling start-sockets results in a <sockets-not-initialized> error. Calling start-sockets from a top-level form in a DLL project will result in unpredictable failures--probably access violations during initialization.
with-socket-thread

System and I/O Reference - 31 MAR 2000

Next Previous Up Top Contents Index