Appendix A: QSOCKET
Rapid-Q Documentation by William Yu (c)1999-2000 |
Appendix A: QSOCKET |
|
QSOCKET Component
QSocket provides an easy to use interface to communicate between server/client with
sockets.
QSocket Properties
Field | Type | R/W | Default | Support |
|
|
|
|
|
Family | INTEGER | RW | AF_INET | W |
| Family specifies the address family.
|
LParam | INTEGER | RW | FD_CONNECT | W |
| LParam specifies the message to capture when you set WMessage and handle the message processing by assigning a new WndProc to your form.
|
MySocket | INTEGER | R | | WXG |
| MySocket stores the result of operations such as Open. So instead of using the return value of Open, you can use the property MySocket.
|
Parent | QFORM | W | | W |
Protocol | INTEGER | RW | IPPROTO_IP | W |
Tag | INTEGER | RW | | WXG |
Transferred | INTEGER | R | | WXG |
Type | INTEGER | RW | SOCK_STREAM | W |
WMessage | INTEGER | RW | 0 | W |
| WMessage specifies a user defined message to be passed to your form for non-blocking calls, ie. Connecting.
|
QSocket Methods
Method | Type | Description | Params | Support |
|
|
|
|
|
Accept | FUNCTION ClientSock%(Socket%) | Accepts Client Connection | 1 | WXG |
Close | SUB (Socket%) | Closes Socket% file descriptor | 1 | WXG |
Connect | FUNCTION Sock%(ServerName$, PortNum%) | Connect to server on PortNum% | 2 | WXG |
ConnectionReady | FUNCTION Bool%(Sock%) | True/False if connection pending | 1 | WXG |
GetHostIP | FUNCTION AS STRING | Returns host IP Address | 0 | WXG |
GetHostName | FUNCTION AS STRING | Returns host name | 0 | WXG |
GetPeerName | FUNCTION GetPeerName$(Socket%) | Returns peer name | 1 | WXG |
IsClientReady | FUNCTION Bool%(Sock%, ClientSock%) | True/False if client is sending data | 2 | WXG |
IsServerReady | FUNCTION Bool%(Sock%) | True/False if server is sending data | 1 | WXG |
Open | FUNCTION Sock%(PortNum%) | Open TCP server on PortNum% | 1 | WXG |
Peek | FUNCTION Peek$(Socket%, NumBytes%) | Peek information coming from socket, but do not clear. Win32 | 2 | W |
Read | FUNCTION Message$(Socket%, NumBytes%) | Read NumBytes% | 2 | WXG |
ReadByte | FUNCTION (Socket%) AS BYTE | Read a single byte | 2 | WXG |
ReadLine | FUNCTION Message$(Socket%) | Read complete line | 1 | WXG |
Write | SUB (Socket%, Message$, NumBytes%) | Sends NumBytes% from Message$ | 3 | WXG |
WriteByte | SUB (Socket%, B AS BYTE) | Sends a single byte | 2 | WXG |
WriteLine | FUNCTION Bytes%(Socket%, Message$) | Send Message$ | 2 | WXG |
QSocket Examples
See the chatserver.bas and chatclient.bas (or chatserv.bas and chatcli.bas for Windows)
included in the Rapid-Q distribution.
Also take a look at http.bas included in the Rapid-Q for Windows distribution.
|
|