TCPX Opcodes

This table contains a brief explanation of the operation of each opcode. Note that in nearly all cases, you'll need to check the return value of the Status parameter to determine the outcome of the operation.

Symbol

Value

Operation

TCPOP_ACCEPT

1

Create listening socket on port specified by sockport, and wait for a client to connect. Be careful to make sure that the buffer parameter is empty, or else the first 32 bytes of it will be sent, unsolicited, to the client immediately after accepting the connection, which is likely to cause confusion unless the client was specifically expecting it.) On successful return, sockport is set to the connected socket, and must be specified to all the other calls for this socket.

TCPOP_WRITE

2

Write buffer to socket.

TCPOP_READ

4

Read buffer from socket.

TCPOP_SHUTDOWN

5

Informs the other end that we are shutting down prior to the close. This is mainly useful when shutting down only one direction. See flags.

TCPOP_CLOSE

6

Close socket. You must do this explicitly when done, since BASIC will not close sockets for you at the end of the program, like it does for files. Note that TCPX will automatically close the socket after certain errors, in which case it will set sockport to -1. In other words, if sockport = -1, don't bother to close it; doing so redundantly is harmless but will return you the error status = -1.

TCPOP_CHECK

7

Check if data available to read; returns status=1 if so, 0 if not, and <0 if the socket has been closed at the other end. Also used with Asynchronous Client Connections and Advanced Server Connection Options to check if the connection is complete or ready to accept.

TCPOP_CHKQTY

8

Check how much data avail to read; return number of bytes in status, <0 indicates socket closed or dropped at other end.

TCPOP_CONNECT

9

(client) Connect to generic server. If timer > 0 and the connection is not established within the specified time, the connection is aborted. See Asynchronous Client Connections.

TCPOP_CONNECT_OLD

10

(client) Equivalent to old TCPCLI opcode 1; now considered archaic

TCPOP_ERRMSG

11

Return system error message corresponding to status.

TCPOP_STARTTLS

12

TCPX opcode to initiate STARTTLS