Symbian3/SDK/Source/GUID-D1BCE2D9-04B5-5C39-A50B-C5BBDAAFEFED.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-D1BCE2D9-04B5-5C39-A50B-C5BBDAAFEFED"><title>Socket Binding</title><shortdesc>This topic describes the concept of socket binding. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody><p>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. </p> <section><title>Explicit socket binding</title> <p>Explicit Socket binding can do the following: </p> <ul><li id="GUID-F3E8228C-FDED-5C9C-9B50-7E8F95F9ED9A"><p>bind an open a socket to a specific <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref>. </p> </li> <li id="GUID-EC175BF9-9A25-576E-BE08-A72B6DA8DDDE"><p>bind an open implicit socket to a specific network interface IP address. </p> </li> </ul> <p>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. </p> <p>Use explicit binding: </p> <ul><li id="GUID-3E804F0C-D85C-5126-8B90-B7CB4E4F28D4"><p>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. </p> <p>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. </p> </li> </ul> <p> <b>Note</b>: TCP/IP uses this type of binding if the destination IP address matches the local address. </p> </section> <section><title>Implicit socket binding</title> <p>Implicit socket binding uses a default bearer to open a socket if the network interface is not specified. In implicit socket binding, <xref href="GUID-406DB549-1102-3DE1-8D7F-56F2394D8F9D.dita"><apiname>Esock</apiname></xref> uses the default <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> or creates an <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref>. When a socket is implicitly bound, the outgoing data goes to the specified port of the default bearer. </p> </section> <section><title>How to Select between Explicit and Implicit Binding</title> <p>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: </p> <ul><li id="GUID-AAD576B6-D5C0-5D1A-A0CA-2864EED5551C"><p>If a user needs secure transfer of data over a specified connection, the user must use explicit socket binding. </p> </li> <li id="GUID-16B55204-6F16-5233-BE60-4F19E45FC56B"><p>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. </p> </li> </ul> </section> <example><title>Explicit and Implicit socket binding example</title> <p>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. </p> <p>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. </p> </example> </conbody><related-links><link href="GUID-8A5054C9-7556-5153-8CEE-FA8E5F4155AE.dita"><linktext>How to Create an Explicitly Bound
                Socket</linktext> </link> <link href="GUID-F79A3DD7-DB91-545F-8165-F1F2DD6D0AD2.dita"><linktext>Creating an Implicitly Bound
                Socket</linktext> </link> </related-links></concept>