68 /** |
83 /** |
69 Second phase constructor. |
84 Second phase constructor. |
70 @param aSocketType The type of the socket. |
85 @param aSocketType The type of the socket. |
71 */ |
86 */ |
72 { |
87 { |
73 switch( aSocketType ) |
88 User::LeaveIfError(Construct(aSocketType)); |
74 { |
89 } |
75 case EProtocolSocket: |
90 |
76 { |
91 TInt CSocket::Construct(TSocketType aSocketType) |
77 if ( iCommsInfoProvider.HasConnection() ) |
92 { |
78 { |
93 TInt error = KErrNone; |
79 // Open a protocol socket with a RConnection |
94 switch( aSocketType ) |
80 User::LeaveIfError(iSocket.Open( |
95 { |
81 iCommsInfoProvider.SocketServer(), |
96 case EProtocolSocket: |
82 iCommsInfoProvider.ProtocolDescription().iAddrFamily, |
97 { |
83 iCommsInfoProvider.ProtocolDescription().iSockType, |
98 if ( iCommsInfoProvider.HasConnection() ) |
84 iCommsInfoProvider.ProtocolDescription().iProtocol, |
99 { |
85 iCommsInfoProvider.Connection() |
100 // Open a protocol socket with a RConnection |
86 )); |
101 error = iSocket.Open(iCommsInfoProvider.SocketServer(), |
87 } |
102 iCommsInfoProvider.ProtocolDescription().iAddrFamily, |
88 else |
103 iCommsInfoProvider.ProtocolDescription().iSockType, |
89 { |
104 iCommsInfoProvider.ProtocolDescription().iProtocol, |
90 // Open a protocol socket without a RConnection, we don't need one ( Loopback address ) |
105 iCommsInfoProvider.Connection() |
91 User::LeaveIfError(iSocket.Open( |
106 ); |
92 iCommsInfoProvider.SocketServer(), |
107 } |
93 iCommsInfoProvider.ProtocolDescription().iAddrFamily, |
108 else |
94 iCommsInfoProvider.ProtocolDescription().iSockType, |
109 { |
95 iCommsInfoProvider.ProtocolDescription().iProtocol |
110 // Open a protocol socket without a RConnection, we don't need one ( Loopback address ) |
96 )); |
111 error = iSocket.Open(iCommsInfoProvider.SocketServer(), |
97 } |
112 iCommsInfoProvider.ProtocolDescription().iAddrFamily, |
98 } break; |
113 iCommsInfoProvider.ProtocolDescription().iSockType, |
99 case EBlankSocket: |
114 iCommsInfoProvider.ProtocolDescription().iProtocol |
100 { |
115 ); |
101 // Open a blank socket |
116 } |
102 User::LeaveIfError(iSocket.Open(iCommsInfoProvider.SocketServer())); |
117 } break; |
103 } break; |
118 case EBlankSocket: |
104 default: |
119 { |
105 User::Invariant(); |
120 // Open a blank socket |
106 } |
121 error = iSocket.Open(iCommsInfoProvider.SocketServer()); |
107 TInt id = iCommsInfoProvider.SessionId(); |
122 } break; |
108 if(id>=0) |
123 default: |
109 { |
124 User::Invariant(); |
110 // set socket option |
125 } |
111 iSocket.SetOpt(KSOHttpSessionId, KSOLHttpSessionInfo, id); |
126 if(error == KErrNone) |
112 iSocket.SetOpt(KSoTcpKeepAlive, KSolInetTcp, KTcpTriggeredKeepAlive); |
127 { |
113 } |
128 TInt id = iCommsInfoProvider.SessionId(); |
114 if(aSocketType != EBlankSocket) |
129 if(id>=0) |
115 { |
130 { |
116 iSocket.SetOpt(KSoTcpNoDelay,KSolInetTcp,1); // Disable the nagle. |
131 // set socket option |
117 iSocket.SetOpt(KSORecvBuf, KSOLSocket, KSocketRecvBufSize); // Set the socket recv buf to be 16K |
132 iSocket.SetOpt(KSOHttpSessionId, KSOLHttpSessionInfo, id); |
118 } |
133 iSocket.SetOpt(KSoTcpKeepAlive, KSolInetTcp, KTcpTriggeredKeepAlive); |
119 } |
134 } |
|
135 if(aSocketType != EBlankSocket) |
|
136 { |
|
137 iSocket.SetOpt(KSoTcpNoDelay,KSolInetTcp,1); // Disable the nagle. |
|
138 iSocket.SetOpt(KSORecvBuf, KSOLSocket, KSocketRecvBufSize); // Set the socket recv buf to be 16K |
|
139 } |
|
140 } |
|
141 return error; |
|
142 } |
120 |
143 |
121 TInt CSocket::Listen(TUint aQSize, TUint16 aPort) |
144 TInt CSocket::Listen(TUint aQSize, TUint16 aPort) |
122 /** |
145 /** |
123 Start the listen service. The socket is bound to the local port specified by |
146 Start the listen service. The socket is bound to the local port specified by |
124 aPort. The listen service is then started. The aQSize argument specifies the |
147 aPort. The listen service is then started. The aQSize argument specifies the |