Action
Returns information of a socket.
Syntax
Result = SOCKETSTAT( socket , mode)
Remarks
Result |
A word variable that is assigned with the result. |
Socket |
The socket number you want to get information of |
Mode |
A parameter that specified what kind of information you want to retrieve.
SEL_CONTROL or 0 : returns the status register value
SEL_SEND or 1 : returns the number of bytes that might be placed into the transmission buffer.
SEL_RECV or 2 : returns the number of bytes that are stored in the reception buffer. |
The SocketStat function contains actual 3 functions. One to get the status of the connection, one to determine how many bytes you might write to the socket, and one to determine how many bytes you can read from the buffer.
When you specify mode 0, one of the following byte values will be returned:
Value |
State |
Description |
0 |
SOCK_CLOSED |
Connection closed |
1 |
SOCK_ARP |
Standing by for reply after transmitting ARP request |
2 |
SOCK_LISTEN |
Standing by for connection setup to the client when acting in passive mode |
3 |
SOCK_SYNSENT |
Standing by for SYN,ACK after transmitting SYN for connecting setup when acting in active mode |
4 |
SOCK_SYNSENT_ACK |
Connection setup is complete after SYN,ACK is received and ACK is transmitted in active mode |
5 |
SOCK_SYNRECV |
SYN,ACK is being transmitted after receiving SYN from the client in listen state, passive mode |
6 |
SOCK_ESTABLISHED |
Connection setup is complete in active, passive mode |
7 |
SOCK_CLOSE_WAIT |
Connection being terminated |
8 |
SOCK_LAST_ACK |
Connection being terminated |
9 |
SOCK_FIN_WAIT1 |
Connection being terminated |
10 |
SOCK_FIN_WAIT2 |
Connection being terminated |
11 |
SOCK_CLOSING |
Connection being terminated |
12 |
SOCK_TIME_WAIT |
Connection being terminated |
13 |
SOCK_RESET |
Connection being terminated after receiving reset packet from peer. |
14 |
SOCK_INIT |
Socket initializing |
15 |
SOCK_UDP |
Applicable channel is initialized in UDP mode. |
16 |
SOCK_RAW |
Applicable channel is initialized in IP layer RAW mode |
17 |
SOCK_UDP_ARP |
Standing by for reply after transmitting ARP request packet to the destination for UDP transmission |
18 |
SOCK_UDP_DATA |
Data transmission in progress in UDP RAW mode |
19 |
SOCK_RAW_INIT |
W3100A initialized in MAC layer RAW mode |
The SocketStat function is also used internally by the library.
See also
CONFIG TCPIP, GETSOCKET , SOCKETCONNECT, TCPWRITE, TCPWRITESTR, TCPREAD, CLOSESOCKET , SOCKETLISTEN
Partial Example
Tempw = Socketstat(i , 0)' get status
Select Case Tempw
Case Sock_established
Case Else
End Select