User Tools

Site Tools


Sidebar

Network and communication

k24:k24.1:k24.1.6:start

24.1.6 Constants of the Net class (gb.net)

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):

  • error values are always negative.
  • Inactivity is always indicated as zero (0).
  • Activities are indicated with positive values.

24.1.6.1 Method Format(...)

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

24.1.6.2 Constants

The static class defines constants used by the classes of the gb.net component. Most constants are linked to the status property.

ConstantValueDescription
CannotAuthenticate-16This error constant indicates that a client socket was unable to authenticate to the server.
CannotBindInterface-15This error constant indicates that the binding of a ServerSocket to a specific interface failed.
CannotListen-14This error constant indicates that a ServerSocket was not able to listen to a TCP port or a local path.
CannotBindSocket-10This error constant indicates that a network socket was unable to use the specified port - to bind to that port.
HostNotFound-6This error constant reflects that an object from one of the network classes was unable to translate a host name into an IP address.
CannotWrite-5This error constant indicates that an error occurred when attempting to write data to a socket or serial port.
CannotRead-4This error constant indicates that an error occurred while trying to read data from a socket or serial port.
ConnectionRefused-3This error constant indicates that a server has refused a connection from a client socket.
CannotCreateSocket-2This error constant indicates that a network object could not create a new socket. The system did not allow this operation.
IPv40Constant used by the Net.Format(…) function for IPv4 addresses.
Local0Defines a local socket or a Unix domain socket.
Unix0Defines a local socket or a Unix domain socket.
Internet1Defines an Internet domain socket.
Inactive0This constant reflects that a network object does nothing - it is inactive.
Active1This constant indicates that a network object is working at this moment.
Pending2This constant reflects that a client is trying to connect to a server socket and the connection has not yet been accepted or rejected.
Accepting3This constant reflects that a remote client is trying to connect to a server socket and that the connection is accepted.
ReceivingData4This constant indicates that data is being received from the network.
Searching5This constant indicates that an object from one of the network classes is trying to translate a host name into an IP address.
Connecting6This constant reflects that a socket, acting like a client socket, is attempting to connect to a remote server.
Connected7This constant reflects that a client socket is connected to a server.

Table 24.1.6.2.1 : Constants of the class Net (gb.net)

24.1.6.3 Examples

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
The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k24/k24.1/k24.1.6/start.txt · Last modified: 18.06.2022 (external edit)

Page Tools