The following chapter introduces the (static) method Format(…) and selected constants of the class Net of the component gb.net.
In general, the following applies to the constants (data type Integer):
The class has only the (static) function
Format ( IPString As String [ , Format As Integer, LeadZero As Boolean ] ) As String
You use it to format a string that represents an IP address. The following applies to the two optional parameters:
For 'Format', currently (20 August 2020) a 0 or the constant `Net.IPv4` must be set.If 'LeadZero' is True, then all 4 octets are padded with zeros in the so-called `Dotted Decimal Notation`:
Print Net.Format("168.55.212.1", Net.IPv4, True) 168.055.212.001
The static class defines constants used by the classes of the gb.net component. Most constants are linked to the status property.
Constant | Value | Description |
---|---|---|
CannotAuthenticate | -16 | This error constant indicates that a client socket was unable to authenticate to the server. |
CannotBindInterface | -15 | This error constant indicates that the binding of a ServerSocket to a specific interface failed. |
CannotListen | -14 | This error constant indicates that a ServerSocket was not able to listen to a TCP port or a local path. |
CannotBindSocket | -10 | This error constant indicates that a network socket was unable to use the specified port - to bind to that port. |
HostNotFound | -6 | This error constant reflects that an object from one of the network classes was unable to translate a host name into an IP address. |
CannotWrite | -5 | This error constant indicates that an error occurred when attempting to write data to a socket or serial port. |
CannotRead | -4 | This error constant indicates that an error occurred while trying to read data from a socket or serial port. |
ConnectionRefused | -3 | This error constant indicates that a server has refused a connection from a client socket. |
CannotCreateSocket | -2 | This error constant indicates that a network object could not create a new socket. The system did not allow this operation. |
IPv4 | 0 | Constant used by the Net.Format(…) function for IPv4 addresses. |
Local | 0 | Defines a local socket or a Unix domain socket. |
Unix | 0 | Defines a local socket or a Unix domain socket. |
Internet | 1 | Defines an Internet domain socket. |
Inactive | 0 | This constant reflects that a network object does nothing - it is inactive. |
Active | 1 | This constant indicates that a network object is working at this moment. |
Pending | 2 | This constant reflects that a client is trying to connect to a server socket and the connection has not yet been accepted or rejected. |
Accepting | 3 | This constant reflects that a remote client is trying to connect to a server socket and that the connection is accepted. |
ReceivingData | 4 | This constant indicates that data is being received from the network. |
Searching | 5 | This constant indicates that an object from one of the network classes is trying to translate a host name into an IP address. |
Connecting | 6 | This constant reflects that a socket, acting like a client socket, is attempting to connect to a remote server. |
Connected | 7 | This constant reflects that a client socket is connected to a server. |
Table 24.1.6.2.1 : Constants of the class Net (gb.net)
You can detect an error by checking whether, for example, the status property for a created socket is negative:
Public hSocket As Socket hSocket = New Socket As EVENTNAME If hSocket.Status < 0 Then ... If hSocket.Status = Net.CannotWrite Then ...
You must only call the Connect() method if you are sure that the socket status returns a negative value or 0:
Public hSocket As Socket hSocket = New Socket As EVENTNAME If hSocket.Status <= 0 Then hSocket.Connect("/var/run/mysqld/mysqld.sock", Net.Local) Endif