1*9d1279ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9d1279ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9d1279ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9d1279ecSAndrew Rist * distributed with this work for additional information
6*9d1279ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9d1279ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9d1279ecSAndrew Rist * "License"); you may not use this file except in compliance
9*9d1279ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*9d1279ecSAndrew Rist *
11*9d1279ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9d1279ecSAndrew Rist *
13*9d1279ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9d1279ecSAndrew Rist * software distributed under the License is distributed on an
15*9d1279ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9d1279ecSAndrew Rist * KIND, either express or implied. See the License for the
17*9d1279ecSAndrew Rist * specific language governing permissions and limitations
18*9d1279ecSAndrew Rist * under the License.
19*9d1279ecSAndrew Rist *
20*9d1279ecSAndrew Rist *************************************************************/
21*9d1279ecSAndrew Rist
22*9d1279ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_automation.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "tcpio.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir /// implement ITransmiter
TransferBytes(const void * pBuffer,comm_UINT32 nLen)30cdf0e10cSrcweir comm_USHORT TCPIO::TransferBytes( const void* pBuffer, comm_UINT32 nLen )
31cdf0e10cSrcweir {
32cdf0e10cSrcweir vos::OGuard aGuard( aMSocketWriteAccess );
33cdf0e10cSrcweir if ( !pStreamSocket )
34cdf0e10cSrcweir {
35cdf0e10cSrcweir nLastSent = 0;
36cdf0e10cSrcweir return C_ERROR_PERMANENT;
37cdf0e10cSrcweir }
38cdf0e10cSrcweir nLastSent = pStreamSocket->write( pBuffer, nLen );
39cdf0e10cSrcweir if ( nLastSent == nLen )
40cdf0e10cSrcweir return C_ERROR_NONE;
41cdf0e10cSrcweir return C_ERROR_PERMANENT;
42cdf0e10cSrcweir }
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir /// implement IReceiver
ReceiveBytes(void * pBuffer,comm_UINT32 nLen)46cdf0e10cSrcweir comm_USHORT TCPIO::ReceiveBytes( void* pBuffer, comm_UINT32 nLen )
47cdf0e10cSrcweir {
48cdf0e10cSrcweir vos::OGuard aGuard( aMSocketReadAccess );
49cdf0e10cSrcweir if ( !pStreamSocket )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir nLastReceived = 0;
52cdf0e10cSrcweir return C_ERROR_PERMANENT;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir nLastReceived = pStreamSocket->read( pBuffer, nLen );
55cdf0e10cSrcweir if ( nLastReceived == nLen )
56cdf0e10cSrcweir return C_ERROR_NONE;
57cdf0e10cSrcweir return C_ERROR_PERMANENT;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir
61cdf0e10cSrcweir // helper
SetStreamSocket(vos::OStreamSocket * pSocket)62cdf0e10cSrcweir void TCPIO::SetStreamSocket( vos::OStreamSocket *pSocket )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir vos::OGuard aRGuard( aMSocketReadAccess );
65cdf0e10cSrcweir vos::OGuard aWGuard( aMSocketWriteAccess );
66cdf0e10cSrcweir pStreamSocket = pSocket;
67cdf0e10cSrcweir }
68