Symbian3/SDK/Source/GUID-B8DEA3EE-7BA7-5A29-9A27-B87EE0EB254F.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 15:24:34 +0100
changeset 9 59758314f811
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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 task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-B8DEA3EE-7BA7-5A29-9A27-B87EE0EB254F" xml:lang="en"><title>Accessing
TCP/IP Sockets Tutorial</title><shortdesc>This topic describes how to access TCP/IP sockets. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq><p>You must be familiar with <codeph>RSocketServ()</codeph> and <codeph>RSocket()</codeph> to
understand this tutorial. </p> </prereq>
<context><p>Client programs access TCP/IP sockets through the generic socket
interface <codeph>RSocket()</codeph>. The <codeph>RSocket()</codeph> specifies
the protocol-specific behaviour through argument values. This tutorial contains
notes on the usage of <codeph>RSocket()</codeph> functions for TCP and UDP
sockets. </p><p> The high level steps to access the TCP/IP sockets are as
follows: </p> </context>
<steps id="GUID-613D3E19-02F2-578A-89AC-B639B8952357">
<step id="GUID-B608A9CE-1A99-5A6F-AE6D-63015A0BE089"><cmd>The <codeph>RSocket()</codeph> function
takes a number of parameters that determine the type of socket connection
to provide. </cmd>
<info>The following are the important parameters for TCP/IP or UDP: </info>
<substeps id="GUID-507B471D-EFD5-5DD2-B457-76AF61A863C9">
<substep id="GUID-1743A72D-3FB7-57CE-AF20-4CB4452334B9"><cmd/>
<info>addrFamily </info>
</substep>
<substep id="GUID-111B511D-1F1B-52FD-8820-8A4F8DF7DB66"><cmd/>
<info>sockType </info>
</substep>
<substep id="GUID-0049E8E2-3A84-5C5D-97ED-09367BA11259"><cmd/>
<info>protocol </info>
</substep>
</substeps>
</step>
<step id="GUID-D63213B5-180D-5B82-A699-4CD1FF8AC066"><cmd/>
<info>The following constant values must be used for TCP/IP: </info>
<info>addrFamily: <codeph>KAfInet</codeph> or <codeph>KAfInet6</codeph> for
IPv6 </info>
<info>sockType: <codeph>KSockStream</codeph> for TCP/IP or <codeph>KSockDatagram</codeph> for
UDP </info>
<info>protocol: <codeph>KProtocolInetTCP</codeph> or <codeph>KProtocolInetUDP</codeph>  </info>
</step>
</steps>
<example><title>Example</title> <p>The following code is an example to access
the TCP/IP socket: </p> <codeblock id="GUID-E61E7089-2F9C-5E8A-ADFB-4BF25451AA59" xml:space="preserve">
void Example::open(void)
{    
    TInt err;
    RSocketServ ss;
    RSocket sock;

    err = ss.Connect();
    err = sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp);
    // ... now connect to the socket to send and receive data
</codeblock> </example>
</taskbody><related-links>
<link href="GUID-61E0CD76-A2E3-5066-84A8-146EECA8ADCD.dita"><linktext>Sockets Server</linktext>
</link>
</related-links></task>