MSMQ를 이용해서 비동기로 컴포넌트를 호출방법

COM+ 컴포넌트
- 해당 컴포넌트는 [out] 파라미터가 없어한다
  [out] 파라미터가 있으면 인터페이스 대기 속성이 disable 되어 있다

- COM+의 패키기의 대기화 속성에 "대기"가 체크되어야한다
  당연히 MSMQ가 설치되어야 한다.

- 수신처리하기 위해서는 "수신처리"를 체크하여 큐에 쌓인 내용을 처리함

- 해당 구성요소의 인터페이스 속성에서 대기화의 "대기"를 체크하여 인터페이스를 대기 시킨다



호출방법
- CoGetObject 함수를 이용해서 Queued Component의 인스턴스를 생성하여 사용한다.
   "queue:/new:QCom.Test"


// C++
IUnknown *pUnknown;
HRESULT hr = CoGetObject(L"queue:/new:QCom.Test", NULL, IID_IUnknown, (void**)&pUnknown);
if (FAILED(hr)) {
    cout << "CoGetObject failed " << endl;
}

// pUnknown 를 해당 인터페이스로 변환하여 사용
// 혹은 직접 인터페이스의 IID_ 및 인터페이스 포인터로 접근하여 사용



http://msdn2.microsoft.com/en-us/library/ms683468.aspx
http://msdn2.microsoft.com/en-us/library/ms686762.aspx

'Dev > Windows' 카테고리의 다른 글

달라진 기능 (IIS 6.0)  (0) 2007.09.28
SQLOLEDB Provider 의 특이한 동작  (0) 2007.09.20
SWC (Services Without Components)  (0) 2007.08.08
RestartService  (0) 2007.07.19
MultiMedia Timer  (0) 2007.05.14

/////////////////////////////////////////////////////////////////////
// C#
using System.EnterpriseServices;

ServiceConfig sc = new ServiceConfig();
sc.TrackingEnabled = true;
sc.Transaction = TransactionOption.Required;
sc.TrackingAppName = "cdecl";
sc.TrackingComponentName = "cdeclcom";

ServiceDomain.Enter(sc);

try {
    Run();
    ContextUtil.SetComplete();
}
catch (Exception ex) {
    ContextUtil.SetAbort();
}

TransactionStatus st = ServiceDomain.Leave();


/////////////////////////////////////////////////////////////////////
// C++ (native)
#include <windows.h>
#include <comsvcs.h>

IUnknown *pUnknown;
HRESULT hr = CoCreateInstance(CLSID_CServiceConfig, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnknown);

IServiceInheritanceConfig *pInher;
hr = pUnknown->QueryInterface(IID_IServiceInheritanceConfig, (void**)&pInher);
hr = pInher->ContainingContextTreatment(CSC_Inherit);

IServiceTrackerConfig *pTracker;
hr = pUnknown->QueryInterface(IID_IServiceTrackerConfig, (void**)&pTracker);
hr = pTracker->TrackerConfig(CSC_UseTracker, L"CDECL_APP", L"CDECL_COM");

IServiceTransactionConfig *pTran;
hr = pUnknown->QueryInterface(IID_IServiceTransactionConfig, (void**)&pTran);
hr = pTran->ConfigureTransaction(CSC_NewTransaction);
hr = pTran->IsolationLevel(COMAdminTxIsolationLevelReadUnCommitted);

CoEnterServiceDomain(pUnknown);

IObjectContext *ctx;
hr = GetObjectContext(&ctx);

try {
    Run();
    ctx->SetComplete();
}
catch (...) {
    ctx->SetAbort();
    cout << "Unknown Exception " << endl;
}

ctx->Release();

CoLeaveServiceDomain(pUnknown);

pTran->Release();
pTracker->Release();
pInher->Release();
pUnknown->Release();



'Dev > Windows' 카테고리의 다른 글

SQLOLEDB Provider 의 특이한 동작  (0) 2007.09.20
COM+ Queued Components  (0) 2007.08.09
RestartService  (0) 2007.07.19
MultiMedia Timer  (0) 2007.05.14
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14

IP Header

Octet Bits Len Name Notes
0 0-3 - Version 4 bits. IP version number. Current version is 4.
0 4-7 - Hdr length 4 bits. Length of IP header in 32 bit words (4 octets). Minimum valid is 5 (20 octets).
1 - 1 ToS 1 octet. Type of Service. Rarely used, often misused or abused.
bit 0-2: Precedence
bit 3: Delay 0 = normal 1 = low
bit 4: Throughtput 0 = normal 1 = high
bit 5: Reliability 0 = normal 1 = high
bit 6-7: Reserved
Precedence
111 Network Control
110 Internetwork Control
101 CRITIC/ECP
100 Flash override
011 Flash
010 Immediate
001 Priority
000 Routine
When used with Explicit Congestion Notification (ECN) (RFC 3168) may take values defined here and here.
2-3 - 2 Total Length 2 Octets. Total length in octets of this packet starting from octet 0 of this header.
4-5 - 2 Identification 2 Octets. Sequence number used when fragmenting IP packets for a given media type.
6 0-3 - Flags 3 bits. Usage
bit 0 - not used = 0
bit 1 (DF) = 1 do not fragment
bit 2 (MF) = 1 more fragments to come
6-7 4-15 - Version 13 bits. Fragment start offset measured in 8 octet (64 bit) units. First fragment is zero.
8 - 1 TTL 1 octet. Time to Live. See notes.
9 - 1 Protocol 1 octet. Protocol. Some common values:
0 (0x00) IPv6 Hop-by-Hop Option
1 (0x01) ICMP protocol
2 (0x02) IGMP protocol
4 (0x04) IP over IP
6 (0x06) TCP protocol
17 (0x11) UDP protocol
41 (0x29) IPv6 protocol
Definitive list is here
10-11 - 1 Checksum 2 octets. See RFCs 1141 & 1624. Covers IP header ONLY.
12-15 - 4 Source 4 octets. Source IP address.
16-19 - 4 Destination 4 octets. Destination IP address.
20+ - ? IP Options Optional. If present must be padded to 32 bit multiples. Definitive list of options is here.
Notes:
  1. Time to Live originally involved a sense of time. It is now used as a simple, but very effective, count to prevent routing errors and loops. Every router that handles the packet decrements the TTL value and if it reaches zero the packet is returned with a ICMP Time Exceeded message. A trace route comand (tracert) is usually a series of ping commands with increasing values of the TTL parameter such that the packet will be returned from each successive router. Called a hop limit in IPv6 to clarify its use.


 

ICMP Header

Internet Control Message Protocol (ICMP) is used to perform many network 'housekeeping' tasks. Each ICMP message has a slightly different format but the first 4 bytes are ALWAYS the same.

Octet Len Name Notes
0 1 ICMP Type ICMP Message Type
0 = echo reply(ping)
3 = destination unreachable
4 = source quench
5 = redirect (route change)
8 = echo request(ping)
11 = time exceeded
12 = Parameter problem
13 = timestamp request
14 = timestamp reply
17 = address mask request
18 = address mask reply
1 1 Code Code values are message specific.
2-3 2 Checksum -

Notes:

  1. Checksum is IP one's complement standard (RFCs 1141 and 1624).

ICMP Echo Request/Response (Ping)

In a ping operation the entire packet is echo'd (or pinged as in ping-pong) back to the sender. A trace route comand (tracert) is usually a series of ping commands with increasing values of the TTL parameter (in IP header) such that it will be returned from each successive router.

Octet Len Name Notes
0 1 ICMP Type Message Type
8 = Echo request
0 = echo reply
1 1 Code Code = 0
2-3 2 Checksum -
4-5 2 Identifier Used by sender to identify operation.
6-7 2 Sequence Used by sender to identify operation.
8+ ? Data Optional Data field.

ICMP Unreachable

The code field specifies the type of error.

Octet Len Name Notes
0 1 ICMP Type Message Type
1 = Host unreachable
1 1 Code 0 = Network unreachable
1 = Host unreachable
2 = Protocol unreachable
3 = Port unreachable
4 = Frag needed but DF set
5 = Source route failed
6 = Destination network unknown
7 = Destination host unknown
8 = Source host isolated
9 = Network access prohibited
10 = Host access prohibited
11 = Network unreachable for ToS
12 = Host unreachable for ToS
2-3 2 Checksum -
4-5 2 Not used Must be zero
6-7 2 Not used Must be zero
8+ ? User Packet IP header plus first 64 bits (8 octets) of failing datagram.

ICMP Source Quench

Great idea but most implementations seem to ignore this polite request to stop sending so much data.

Octet Len Name Notes
0 1 ICMP Type Message Type
4 = Source Quench
1 1 Code Always 0
2-3 2 Checksum -
4-5 2 Not used Must be zero
6-7 2 Not used Must be zero
8+ ? User Packet IP header plus first 64 bits (8 octets) of last datagram.

ICMP Redirect

Indicates the host should use the specified gateway to reach the IP address contained in the returned message.

Octet Len Name Notes
0 1 ICMP Type Message Type
5 = ICMP redirect
1 1 Code May take one of the following values 0 = redirect datagrams for net (obsolete)
1 = redirect datagrams for host
2 = redirect datagrams for ToS and net
3 = redirect datagrams for Tos and host
2-3 2 Checksum -
4-7 4 Gateway IP Specifies that, for the destination host in the returned datagram, this gateway should be used.
8+ ? User Packet IP header plus first 64 bits (8 octets) of failing datagram.

ICMP Time Exceeded

Message returned by the discovering router when the TTL count reaches 0 in the IP header or timeout problem with fragmentation.

Octet Len Name Notes
0 1 ICMP Type Message Type
11 = ICMP Time Exceeded
1 1 Code May take one of the following values 0 = Time to Live count = 0 (exceeded)
1 = fragment reassembly time exceeded
2-3 2 Checksum -
4-7 4 Unused must be zero.
8+ ? User Packet IP header plus first 64 bits (8 octets) of failing datagram.


 

UDP Header

UDP (User Datagram Protocol) is a connectionless protocol and represents a lightweight method of sending and receiving data.

Octet Len Name Notes
0-1 2 Source port -
2-3 2 Destination Port Reserved (well-known) port numbers are here
4-5 2 UDP Length Length of UDP packet starting from Octet 0.
6-7 2 Checksum Optional. 0 = no checksum. The value 0xFFFFFFFF is a computed checksum of 0. See also UDP pseudo header
Notes
  1. UDP Checksum. If a UDP checksum is present (optional for IPv4, mandatory for IPv6) it is assumed to have a 'psuedo header' field of the following format prepended to the data:
    Octet Len Name Notes
    0-3 4 Source Source IP address
    4-7 4 Destination Destination IP address
    8 1 Zero Always zero
    9 1 Protocol Always 17 for UDP
    10-11 2 Length Length of UDP packet (excluding this psuedo header)

    The UDP checksum is computed by including the above 'pseudo header' plus the total UDP packet including the 'real' UDP header.

  2. Checksum is IP one's complement standard (RFCs 1141 and 1624).


 

TCP Header

TCP (Transmission Control Protocol) is a connection-oriented protocol (it has opens and closes and stuff) and provides secure data transfer (the protocol includes ACKs and stuff). You can get the same level of service using UDP but you have to 'hand-carve' the opening, closing and ACK processes. TCP is incredibly efficient and its windowing mechanism especially provides very fast network performance adaptive feedback.

Octet Bits Len Name Notes
0-1 - 2 Source port -
2-3 - 2 Destination Port -
4-7 - 4 Sequence number position of last octet we sent.
8-11 - 4 Acknowledge Number Next octet number we expect from the peer.
12 0-3 - HLEN 4 bits. The number of 32 bit multiples (4 octets) in the TCP header including any 'options' fields.
12 4-7 - Reserved should be zero
13 - 1 Code bits 8 bits (6 used) valid if 1
bit 0 (URG) Urgent
bit 1 (ACK) Acknowledgement
bit 2 (PSH) Requests PUSH
bit 3 (RST) Reset connection
bit 4 (SYN) Sync sequence numbers
bit 5 (FIN) sender finished
14-15 - 2 Window Specifies the amount of data we can accept.
16-17 - 2 Checksum Standard IP checksum. Includes a TCP pseudo header.
18-19 - 2 Urgent pointer Points to end of urgent data.
TCP Options
TCP data
NOTES:
  1. The TCP checksum is assumed to have a 'psuedo header' field of the following format prepended to the data:
    Octet Len Name Notes
    0-3 4 Source Source IP address
    4-7 4 Destination Destination IP address
    8 1 Zero Always zero
    9 1 Protocol Always 6 for TCP
    10-11 2 Length Length of TCP packet (excluding this psuedo header)

    The TCP checksum is computed by including the above pseudo header plus the total TCP packet including the real TCP header.

  2. Checksum is IP one's complement standard (RFCs 1141 and 1624).

TCP Options

TCP allows a number of options sent with the SYN command. Option list MUST be padded with zeros (end of list option) to a multiple of 32 bits. Options may be one byte or multiple bytes (TLD format) in this case octet 2 is always the length value, octet 3+ contains data.

Currently defined options are (exhaustive list is here):

Octet 0 Type Len Data Name
0 One byte 1 - End of option list
1 One byte 1 - Padding (MAY be used to align data)
2 TLD 4 max segment size Segment size option


 

'Dev > Network' 카테고리의 다른 글

tcpdump 옵션  (0) 2013.04.08
TCP Connection Establishment Procedure & Connection Termination Procedure  (0) 2012.03.30
SSL Protocol  (0) 2007.09.08

void RestartService(std::string strServiceName)
{
    SC_HANDLE hSCM = NULL;
    SC_HANDLE hDns = NULL;

    try {
        hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
        if (!hSCM) {
            cout << "OpenSCManager Error" << endl;
            throw -1;
        }

        hDns = OpenService(hSCM, strServiceName.c_str(), SERVICE_ALL_ACCESS);
        if (!hDns) {
            cout << "OpenService Error" << endl;
            throw -1;
        }

        SERVICE_STATUS schStatus = {0, };

        BOOL bStop = ControlService(hDns, SERVICE_CONTROL_STOP, &schStatus);

        if (bStop) {
            cout << strServiceName << " Stop" << endl;
        }

        BOOL bStart = StartService(hDns, 0, NULL);

        if (bStart) {
            cout << strServiceName << " Start" << endl;
        }
    }
    catch (...) {}

    if (hDns) {
        CloseServiceHandle(hDns);
    }
   
    if (hSCM) {
        CloseServiceHandle(hSCM);
    }
}

'Dev > Windows' 카테고리의 다른 글

COM+ Queued Components  (0) 2007.08.09
SWC (Services Without Components)  (0) 2007.08.08
MultiMedia Timer  (0) 2007.05.14
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
팀장 딜레마에 관한 글

http://channy.creation.net/blog/?p=426

'일상' 카테고리의 다른 글

생각의 정리..  (0) 2008.12.17
회의를 좋아하는 매니저의 특징  (0) 2008.09.17
꼬마 바보..  (0) 2006.11.06
딜마 아쌈 - t시리즈  (0) 2006.11.01
위타드 기문 홍차..  (0) 2006.10.25

'Dev > C++' 카테고리의 다른 글

tr1::regex (boost::regex) 샘플코드  (0) 2007.10.21
boost 를 이용한 TR1 Library 사용하기  (0) 2007.10.10
Unhandled C++ Exceptions  (0) 2007.06.19
OutputDebugString  (0) 2007.05.23
C++0x  (0) 2007.05.16
#include <iostream>
using namespace std;
void term_func()
{ cout << "term_func was called by terminate." << endl; exit( -1 ); }
int main()
{ try { set_terminate( term_func ); throw "Out of memory!"; // No catch handler for this exception } catch( int ) { cout << "Integer exception raised." << endl; }
return 0; }

'Dev > C++' 카테고리의 다른 글

boost 를 이용한 TR1 Library 사용하기  (0) 2007.10.10
VC++ 2005 배포  (0) 2007.06.22
OutputDebugString  (0) 2007.05.23
C++0x  (0) 2007.05.16
GRETA  (0) 2007.05.14


// printf 포맷을 이용하는 OutputDebugString 함수
void Trace(LPCTSTR szFormat, ...)
{
    enum { BUFF_SIZE = 2048 };

    TCHAR szTempBuf[BUFF_SIZE] ;
    va_list vlMarker ;

    va_start(vlMarker,szFormat) ;
    _vstprintf(szTempBuf,szFormat,vlMarker) ;
    va_end(vlMarker) ;

    OutputDebugString(szTempBuf) ;
}

'Dev > C++' 카테고리의 다른 글

VC++ 2005 배포  (0) 2007.06.22
Unhandled C++ Exceptions  (0) 2007.06.19
C++0x  (0) 2007.05.16
GRETA  (0) 2007.05.14
A non-type template-parameter  (0) 2007.05.14

'Dev > C++' 카테고리의 다른 글

Unhandled C++ Exceptions  (0) 2007.06.19
OutputDebugString  (0) 2007.05.23
GRETA  (0) 2007.05.14
A non-type template-parameter  (0) 2007.05.14
Member template specialization  (0) 2007.05.14
콘솔에서 Timer 이벤트 처리 방법을 찾다가 발견한 것.
일명 멀티미디어 타이머라 불리는 ..

일반적인 윈도우의 Timer API 보다 정확도가 높고 윈도우 큐를 이용하지 않아 윈도우 없이도 사용 할수 있다는 장점.


About Multimedia Timers

Multimedia Timer Functions

'Dev > Windows' 카테고리의 다른 글

SWC (Services Without Components)  (0) 2007.08.08
RestartService  (0) 2007.07.19
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
DLL export  (0) 2007.05.14

'Dev > Windows' 카테고리의 다른 글

RestartService  (0) 2007.07.19
MultiMedia Timer  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
DLL export  (0) 2007.05.14
_beginthread, _beginthreadex  (0) 2007.05.14
1. The directory from which the application loaded.

2. The current directory.

3. The system directory. Use the GetSystemDirectory function to get the path of this directory.

4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.

5. The directories that are listed in the PATH environment variable.

--
LoadLibrary혹은 DLL을 동적링크할때 특정경로에 관계없이 응용프로그램의 디렉토리에서 먼저 DLL을 로드 하려면 ...

응용프로그램이름 뒤에 ".local" 이란 이름을 가진 빈 파일을 생성한다.
예를들어 응용프로그램 이름이 foo.exe 일때 foo.exe.local 이란 빈 파일을 생성하면 사용하는 DLL을 현재 디렉토리에 있는것 먼저 로드 시킨다.

'Dev > Windows' 카테고리의 다른 글

MultiMedia Timer  (0) 2007.05.14
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL export  (0) 2007.05.14
_beginthread, _beginthreadex  (0) 2007.05.14
서버 개체 오류 'ASP 0177 : 800401f3'  (1) 2007.03.29

+ Recent posts