Can anybody help me by checking if I have correct call signatures?
In my C# Windows Form project (VS2008) I am using dll which has been
written for Visual C++ 6.0:
This function code is used to start receive active message of ioLogik
2000 Ethernet Module:
C/C++
int Message2K_Start( int iProtocol, WORD wPort, pfnCALLBACK&
iProcAddress);
Callback Function
void FunctionName( BYTE bytData[], WORD wSize );
Arguments:
iProtocol : Transmission protocol. 1: TCP 2: UDP
wPort :TCP or UDP port number.
iProcAddress : Callback function, which is called after receive an
active message form ioLogik 2000 Ethernet module.
bytData : An array that stores the message.
wSize : Array size.
Normally in VS C++ I would do like this:
void CALLBACK getUdpMessage( BYTE data[], WORD wSize ); //UDP call
back function
//****************************
// start TCP active message
//****************************
Message2K_Start( PROTOCOL_TCP, 9000, getTcpMessage ); //where: tcp,
port, call back function
Using C#
I have converted this to:
private static extern int Message2K_Start( int iProtocol, int wPort,
CallbackDelegate iProcAddress);
//The signature for the callback method
public delegate void CallbackDelegate(byte [] data, int size);
CallbackDelegate delLine = new CallbackDelegate(getTcpMessage);
//defined call back function:
public static void getTcpMessage( byte [] data, int wSize)
{
wasIcalled = true;
}
and in the code I call:
Message2K_Start(1, 9000, getTcpMessage);
but it return error: "The error occured when the Windows system
couldn't initialized Socket"
Did I make a correct call signatures in C#?