Socket Binding

This topic describes the concept of socket binding.

Socket binding is process of binding a socket to a network address within the system. When a socket is bound the server can accept client connections. There are two types of socket binding, explicit and implicit socket binding which are explained in the following sections.

Explicit socket binding

Explicit Socket binding can do the following:

  • bind an open a socket to a specific RConnection.

  • bind an open implicit socket to a specific network interface IP address.

An explicitly bound socket accepts data only from the interface the explicit socket is bound to. When a socket is explicitly bound, the outgoing data goes to the specified bearer and the socket receives data only from that bearer. Explicit socket binding provides secure data transfer to a specific bearer. Secure data transfer is done to monitor the data transfer, or when the application is bearer-specific.

Use explicit binding:

  • If an application opens a socket to a specific IP address of the network interface and accepts data only from the interface the socket is bound to.

    For example, if an application opens a socket for the TCP protocol and explicitly binds it to the WiFi interface, then the socket accepts data only from the WiFi interface.

Note: TCP/IP uses this type of binding if the destination IP address matches the local address.

Implicit socket binding

Implicit socket binding uses a default bearer to open a socket if the network interface is not specified. In implicit socket binding, Esock uses the default RConnection or creates an RConnection. When a socket is implicitly bound, the outgoing data goes to the specified port of the default bearer.

How to Select between Explicit and Implicit Binding

Explicit sockets accept data from the specified connection the socket is bound to. Implicit sockets accept data from any connection. A user can select between explicit or implicit socket binding in the following ways:

  • If a user needs secure transfer of data over a specified connection, the user must use explicit socket binding.

  • If a user need not know how the data is transferred or where the socket connects to, then the user can use implicit socket binding.

Explicit and Implicit socket binding example

If WiFi and Ethernet bearers are started and TCP protocol socket is opened and explicitly bound to the WiFi interface then, the socket is set to accept a TCP connection. A remote host trying to connect over Ethernet using TCP fails to connect as the socket is explicitly bound to WiFi.

In implicit socket binding, if an application opens an implicit socket using the default interface connection and does not bind to any port, then the socket receives data from all the interfaces. A chat application is an example of implicit socket binding where the network interface is not important and messages can come from GPRS or WiFi.

Related concepts

Related tasks