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