sockets
The file builtins/sockets.e (not an autoinclude) contains routines for low-level handling of network sockets.
Most (client) applications will not use sockets directly, but although libcurl can perform all client-related application needs (in a much simpler and better tested way), it does not contain any server-side handling, for which sockets.e can (perhaps) be used. There may also be some cases where the full might and power of libcurl is not needed, or at least not worth the hassle of ensuring the required dll/so are distributed and installed.
Based heavily on the work of Brett A. Pantalone (Windows), and Irv Mullins, jbrown and Pete Eberlein (Linux), the file builtins/sockets.e (not an autoinclude) is intended to unify those code bases into a single cross-platform file, while adding 64-bit support (achieved via extensive reworking to cffi). At the time of writing, the library is Windows only, however the Linux API is apparently almost identical, so (touch wood) it should be fairly straightforward (any volunteers?).
See demo\pGUI\Chat.exw, demo\rosetta\SimpleHttpServer.exw and demo\rosetta\Sockets.exw for examples of use.
As you can clearly see, there is no real attempt to explain socket programming in any depth, such things (done far better than I ever could) can be found easily enough. This is just a quick lookup of (Phix) result & parameter types, and is more suited to translating existing code than anything else.
None of these routines are supported by pwa/p2js.
Note that none of these routines have yet undergone any significant real-world testing, but should be fairly easy to fix/enhance as needed.
Error handling is most likely wholly inadequate, and many constants are as yet missing, as no doubt are some other useful routines.
Most (client) applications will not use sockets directly, but although libcurl can perform all client-related application needs (in a much simpler and better tested way), it does not contain any server-side handling, for which sockets.e can (perhaps) be used. There may also be some cases where the full might and power of libcurl is not needed, or at least not worth the hassle of ensuring the required dll/so are distributed and installed.
Based heavily on the work of Brett A. Pantalone (Windows), and Irv Mullins, jbrown and Pete Eberlein (Linux), the file builtins/sockets.e (not an autoinclude) is intended to unify those code bases into a single cross-platform file, while adding 64-bit support (achieved via extensive reworking to cffi). At the time of writing, the library is Windows only, however the Linux API is apparently almost identical, so (touch wood) it should be fairly straightforward (any volunteers?).
See demo\pGUI\Chat.exw, demo\rosetta\SimpleHttpServer.exw and demo\rosetta\Sockets.exw for examples of use.
As you can clearly see, there is no real attempt to explain socket programming in any depth, such things (done far better than I ever could) can be found easily enough. This is just a quick lookup of (Phix) result & parameter types, and is more suited to translating existing code than anything else.
None of these routines are supported by pwa/p2js.
constants
| = 0 |
AF_UNIX | = 1 |
AF_INET | = 2 |
SOCK_STREAM | = 1 |
SOCK_DGRAM | = 2 |
INVALID_SOCKET | = #FFFFFFFF |
INADDR_ANY | = 0 |
INADDR_NONE | = INVALID_SOCKET |
SOCKET_ERROR | = -1 |
SD_RECEIVE | = 0, -- Shutdown receive operations. |
SD_SEND | = 1, -- Shutdown send operations. |
SD_BOTH | = 2 -- Shutdown both send and receive operations. |
SOL_SOCKET | = #FFFF |
SO_RCVTIMEO | = #1006 |
routines
sequence res = |
|
atom hSocket = |
|
atom long = |
|
atom long = |
|
integer short = |
|
integer short = |
|
atom pSockAddr = |
|
integer port = |
|
atom addr = |
|
atom addr = |
|
atom pSockAddr = |
|
integer res = |
|
integer res = |
|
integer res = |
|
|
|
atom peer = |
|
|
|
|
|
procedure |
|
procedure |
|
procedure |
|
atom res = |
|
procedure |
|
Note that none of these routines have yet undergone any significant real-world testing, but should be fairly easy to fix/enhance as needed.
Error handling is most likely wholly inadequate, and many constants are as yet missing, as no doubt are some other useful routines.