How to create a simple beaming application

Primary — SEND

RSocketServ   ss;
TProtocolDesc pInfo;
TInt          ret;

ss.Connect();

_LIT8(KTinyTP,"IrTinyTP");
ret=ss.FindProtocol(KTinyTP,protoInfo);
// IrTinyTP is the reliable transport layer of IRDA
if (ret!=KErrNone)
 {
 // Error - protocol not loaded - prob. wrong ESOCK.INI
 // or protocol has locked serial port.
 }
RHostResolver hr1;
ret=hr1.Open(ss,pInfo.iAddrFamily,pInfo.iSockType);
TNameEntry log;
THostName name;
ret=hr1.GetByName(name,log);
if (ret!=KErrNone)
 {
 // No devices discovered - may be none present
 }
RSocket sender;
sender.Open(ss,pInfo.iAddrFamily,pInfo.iSockType,pInfo.iProtocol);
log().iAddr.SetPort(KBeamPortNumber);
TRequestStatus stat;
sender.Connect(log().iAddr,stat);
User::WaitForRequest(stat);
TBuf<100> b;
b.FillZ();
sender.Write(b,stat);
User::WaitForRequest(stat);
sender.Read(b,stat);
User::WaitForRequest(stat)

etc...

Secondary — RECEIVE

RSocketServ   ss;
TProtocolDesc pInfo;
TInt          ret

ss.Connect();

_LIT8(KTinyTP,"IrTinyTP");
ret=ss.FindProtocol(KTinyTP,pInfo);
// IrTinyTP is the reliable transport layer of IRDA
if (ret!=KErrNone) 
 {
 // Error - protocol not loaded: prob. wrong ESOCK.INI
 // or another protocol holds serial port
 }
RSocket listener;
sock.Open(ss,pInfo.iAddrFamily,pInfo.iSockType,pInfo.iProtocol);
TSockAddr a;
a.SetPort(KBeamPortNumber);
listener.Bind(a);
listener.Listen(1); 
RSocket acceptor;
acceptor.Open(ss); // Create a null socket to hold the connection
TRequestStatus stat;
listener.Accept(acceptor,stat);
User::WaitForRequest(stat);  // con now holds the connected socket
TBuf<100> b;
b.FillZ();
acceptor.Read(b,stat); // Reading from accepted socket.
User::WaitForRequest(stat);
acceptor.Write(b,stat);
User::WaitForRequest(stat);

etc...