-
Notifications
You must be signed in to change notification settings - Fork 4
QWSSocket Porting Notes (UNIX Domain Socket only)
QWSSocket Notes
Background
-
Qt Embedded uses QWSSocket and QWSServerSocket as the communication mechanism between QWSServer and QWSClient.
-
Both QWSSocket/QWSServerSocket are #define-d to be either QUnixSocket/QUnixSocketServer or QTcpSocket/QTcpServer depending on the value of "QT_NO_SXE".
QWSSocket Inheritance Tree
-
QWSSocket inherits from QWS_SOCK_BASE
- QWS_SOCK_BASE is either QUnixSocket or QTcpSocket
-
QWSServerSocket inherits from QWS_SOCK_SERVER_BASE
- QWS_SOCK_SERVER_BASE is either QUnixSocketServer or QTcpServer
Qt and Unix Domain Socket
-
Localhost-only socket using file descriptor (using file path instead of addresses as in network sockets). QWSServer/QWSClient calls qws_qtePipeFileName() to get this path.
- TODO: Find out this naming convention and provide similar ability for our channels port.
-
Can send data and ancillary messages (file descriptors and credentials). "man 7 unix" for more info on ancillary messages.
- TODO: Find out if Qt uses any ancillary messages besides data. Without ancillary messages, our QWSSocket port using channels will be easier.
-
Qt uses the regular socket functions to set up Unix domain sockets. This includes calls to socket(), setsockopt(), bind(), listen(), accept(), connect(), close(), select(), sendmsg(), recvmsg().
- Note that Qt calls select() for checking for data to read within a specified amount of time. In our case, we can simply do polling (not poll() call) and use some sleeping mechanism to achieve this effect, though we'll waste CPU cycles.
- TODO: Provide these similar interface on top of our channels. We can use "channel" prefix to distinguish the two version and mass-replace them with sed or something.
Porting Approach
-
We should make new files to replace qunixsocket* and qunixsocketserver while keeping the same interface.
-
On calls that we don't support, e.g. ancillary messages, we can simply print out an error message.
-
Right now there are two big tasks:
- TODO 1. Implement the socket calls above on top of our channels
- TODO 2. Re-implement QUnixSocket and QUnixSocketServer on top of our wrappers of socket calls from part 1.
Relevant Files
- qwsutils_qws.h
- qwssocket_qws.*
- qunixsocket*
- qunixsocketserver*
- qwindow_system_qws.*
References
- Qt Embedded source (src/gui/)
- Man pages