diff options
Diffstat (limited to 'sal/qa/osl/socket/osl_StreamSocket.cxx')
-rw-r--r-- | sal/qa/osl/socket/osl_StreamSocket.cxx | 122 |
1 files changed, 22 insertions, 100 deletions
diff --git a/sal/qa/osl/socket/osl_StreamSocket.cxx b/sal/qa/osl/socket/osl_StreamSocket.cxx index 9883511cb43e..e1058fc37b6c 100644 --- a/sal/qa/osl/socket/osl_StreamSocket.cxx +++ b/sal/qa/osl/socket/osl_StreamSocket.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -54,18 +55,15 @@ inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const; */ -//------------------------------------------------------------------------ -// include files -//------------------------------------------------------------------------ - #include <testshl/simpleheader.hxx> -//#include "osl_Socket_Const.h" #include "sockethelper.hxx" #include <osl/conditn.hxx> using namespace osl; -using namespace rtl; + +using ::rtl::OUString; +using ::rtl::OString; #define IP_PORT_MYPORT9 8897 #define IP_PORT_MYPORT10 18900 @@ -142,7 +140,7 @@ protected: void SAL_CALL run( ) { ::osl::AcceptorSocket asAcceptorSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9 ); + ::osl::SocketAddr saLocalSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9 ); ::osl::StreamSocket ssStreamConnection; //if has not set this option, socket addr can not be binded in some time(maybe 2 minutes) by another socket @@ -252,7 +250,7 @@ protected: public: ClientSocketThread( osl::Condition &_aCond ): m_aCondition(_aCond), - m_saTargetSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9 ), + m_saTargetSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9 ), m_csConnectorSocket( ) { m_id = getIdentifier( ); @@ -335,7 +333,7 @@ protected: void SAL_CALL run( ) { - ::osl::SocketAddr m_aTargetSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT10 ); + ::osl::SocketAddr m_aTargetSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT10 ); ::osl::ConnectorSocket m_aConnectorSocket; if (! m_aTargetSocketAddr.is()) @@ -416,7 +414,7 @@ protected: { t_print("start WriteSocketThread\n"); ::osl::AcceptorSocket asAcceptorSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT10 ); + ::osl::SocketAddr saLocalSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT10 ); if (! saLocalSocketAddr.is()) { t_print("LocalSocketAddr was NOT created successfully!\n"); @@ -460,31 +458,6 @@ protected: else { -// LLA: removed, due to the fact, this is to error prone -// LLA: char * pSrcRoot = getenv("SOURCE_ROOT"); -// LLA: // LLA: This is absolute wrong! -// LLA: // strcat( pSrcRoot, "/sal/inc/osl/file.hxx"); -// LLA: rtl::OString sSrcRoot(pSrcRoot); -// LLA: sSrcRoot += "/sal/inc/osl/file.hxx"; -// LLA: -// LLA: ::rtl::OUString sFilePath = ::rtl::OUString::createFromAscii( sSrcRoot.getStr() ); -// LLA: #ifdef WNT -// LLA: while (sFilePath.lastIndexOf('/') != -1) -// LLA: sFilePath = sFilePath.replace('/',(sal_Unicode)'\\'); -// LLA: #endif -// LLA: FILE *stream; -// LLA: sal_uInt64 nCount_read; -// LLA: sal_Char buffer_read[FILE_READ]; -// LLA: -// LLA: if( (stream = fopen( oustring2char( sFilePath ), "r+t" )) != NULL ) -// LLA: { -// LLA: /* Attempt to read in 25 characters */ -// LLA: nCount_read = fread( buffer_read, sizeof( char ), FILE_READ, stream ); -// LLA: fclose( stream ); -// LLA: } -// LLA: else -// LLA: t_print("# File $SRC_ROOT/sal/inc/osl/file.hxx could not be opened\n" ); - t_print("write()\n"); ssStreamConnection.write( m_aValues.getBuffer(), m_aValues.getBufferSize() ); @@ -640,7 +613,7 @@ namespace osl_StreamSocket void send_recv2() { ::osl::AcceptorSocket asAcceptorSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9 ); + ::osl::SocketAddr saLocalSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9 ); ::osl::StreamSocket ssStreamConnection; sal_Char pReadBuffer[30] = ""; @@ -760,7 +733,7 @@ namespace osl_StreamSocket } public: SendClientThread( ): - m_saTargetSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9 ), + m_saTargetSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9 ), m_csConnectorSocket( ) { //t_print("# successfully creat this SendClientThread %d!\n", m_id ); @@ -792,7 +765,7 @@ namespace osl_StreamSocket { #if defined(LINUX) ::osl::AcceptorSocket asSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - AcceptorThread myAcceptorThread( asSocket, rtl::OUString::createFromAscii("127.0.0.1") ); + AcceptorThread myAcceptorThread( asSocket, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")) ); myAcceptorThread.create(); thread_sleep( 1 ); @@ -809,7 +782,7 @@ namespace osl_StreamSocket void shutdown_002() { ::osl::AcceptorSocket asSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9); + ::osl::SocketAddr saLocalSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9); asSocket.setOption( osl_Socket_OptionReuseAddr, 1 ); CPPUNIT_ASSERT_MESSAGE("shutdown_002: bind fail", asSocket.bind( saLocalSocketAddr ) == sal_True); CPPUNIT_ASSERT_MESSAGE("shutdown_002: listen fail", asSocket.listen( 1 ) == sal_True ); @@ -862,7 +835,7 @@ namespace osl_StreamSocket void shutdown_003() { ::osl::AcceptorSocket asSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); - ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("127.0.0.1"), IP_PORT_MYPORT9); + ::osl::SocketAddr saLocalSocketAddr( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("127.0.0.1")), IP_PORT_MYPORT9); asSocket.setOption( osl_Socket_OptionReuseAddr, 1 ); CPPUNIT_ASSERT_MESSAGE("shutdown_002: bind fail", asSocket.bind( saLocalSocketAddr ) == sal_True); CPPUNIT_ASSERT_MESSAGE("shutdown_002: listen fail", asSocket.listen( 1 ) == sal_True ); @@ -929,59 +902,6 @@ namespace osl_StreamSocket }; // class isExceptionPending // ----------------------------------------------------------------------------- -/** Server Socket Thread, write a file which is large - */ -// LLA: class WriteSocketThread : public Thread -// LLA: { -// LLA: ValueCheckProvider m_aValues; -// LLA: -// LLA: protected: -// LLA: oslThreadIdentifier m_id; -// LLA: -// LLA: void SAL_CALL run( ) -// LLA: { -// LLA: ::osl::AcceptorSocket asAcceptorSocket( osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream ); -// LLA: ::osl::SocketAddr saLocalSocketAddr( rtl::OUString::createFromAscii("10.16.66.252"), 8888 ); -// LLA: ::osl::StreamSocket ssStreamConnection; -// LLA: -// LLA: //if has not set this option, socket addr can not be binded in some time(maybe 2 minutes) by another socket -// LLA: asAcceptorSocket.setOption( osl_Socket_OptionReuseAddr, 1 ); //sal_True); -// LLA: -// LLA: /// if the thread should terminate, schedule return false -// LLA: while ( schedule( ) == sal_True ) -// LLA: { -// LLA: sal_Bool bOK1 = asAcceptorSocket.bind( saLocalSocketAddr ); -// LLA: if ( sal_True != bOK1 ) -// LLA: { -// LLA: t_print("# WriteSocketThread: AcceptorSocket bind address failed. \n" ) ; -// LLA: break; -// LLA: } -// LLA: sal_Bool bOK2 = asAcceptorSocket.listen( 1 ); -// LLA: if ( sal_True != bOK2 ) -// LLA: { -// LLA: t_print("# WriteSocketThread: AcceptorSocket listen address failed. \n" ) ; -// LLA: break; -// LLA: } -// LLA: // blocking mode, if read/recv failed, block until success -// LLA: asAcceptorSocket.enableNonBlockingMode( sal_False); -// LLA: -// LLA: oslSocketResult eResult = asAcceptorSocket.acceptConnection( ssStreamConnection ); -// LLA: if (eResult != osl_Socket_Ok ) -// LLA: { -// LLA: t_print("WriteSocketThread: acceptConnection failed! \n"); -// LLA: break; -// LLA: } -// LLA: -// LLA: -// LLA: sal_Int32 nReadNumber1 = ssStreamConnection.write( m_aValues.getBuffer(), m_aValues.getBufferSize() ); -// LLA: break; -// LLA: } -// LLA: ssStreamConnection.close(); -// LLA: asAcceptorSocket.close(); -// LLA: } -// LLA: } -// ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- /** Client Socket Thread, served as a temp little client to communicate with server. */ @@ -1221,9 +1141,9 @@ namespace osl_StreamSocket public: // LLA: orig void send_recv() // LLA: orig { -// LLA: orig if ( ifAvailable(rtl::OUString::createFromAscii("margritte.germany")) == sal_True ) +// LLA: orig if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("margritte.germany"))) == sal_True ) // LLA: orig t_print("margritte is alive ! \n"); -// LLA: orig if ( ifAvailable(rtl::OUString::createFromAscii("10.16.66.252")) == sal_False ) +// LLA: orig if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10.16.66.252"))) == sal_False ) // LLA: orig { // LLA: orig t_print("ip 10.16.66.252 is not alive! \n"); // LLA: orig return; @@ -1302,7 +1222,7 @@ namespace osl_StreamSocket void send_recv() { rtl::OString sAddr; - // if ( ifAvailable(rtl::OUString::createFromAscii("margritte.germany")) == sal_True ) + // if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("margritte.germany"))) == sal_True ) // { // t_print("margritte is alive ! \n"); // sAddr = "margritte.germany"; @@ -1315,21 +1235,21 @@ namespace osl_StreamSocket } // else // { -// if ( ifAvailable(rtl::OUString::createFromAscii("192.168.7.2")) == sal_True ) +// if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("192.168.7.2"))) == sal_True ) // { // sAddr = "192.168.7.2"; // t_print("moon found ! \n"); // } // else // { -// if ( ifAvailable(rtl::OUString::createFromAscii("moon.linux.bogus")) == sal_True ) +// if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("moon.linux.bogus"))) == sal_True ) // { // sAddr = "moon.linux.bogus"; // t_print("moon found ! \n"); // } // else // { -// if ( ifAvailable(rtl::OUString::createFromAscii("moon")) == sal_True ) +// if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("moon"))) == sal_True ) // { // sAddr = "moon"; // t_print("moon found ! \n"); @@ -1338,7 +1258,7 @@ namespace osl_StreamSocket // } // } - // if ( ifAvailable(rtl::OUString::createFromAscii("10.16.64.196")) == sal_False ) + // if ( ifAvailable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10.16.64.196"))) == sal_False ) // { // t_print("ip 10.16.64.196 is not alive! \n"); // return; @@ -1504,3 +1424,5 @@ namespace osl_StreamSocket // this macro creates an empty function, which will called by the RegisterAllFunctions() // to let the user the possibility to also register some functions by hand. NOADDITIONAL; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |