OTSndUData - problem on Mac OS 9
OTSndUData - problem on Mac OS 9
- Subject: OTSndUData - problem on Mac OS 9
- From: Igor garnov <email@hidden>
- Date: Mon, 16 Feb 2004 17:20:28 +0300
Hello,
I experience a problem with my application on Mac OS 9.
My task is among others to ping a range of hosts. To do that, I create
one endpoint with the following code:
OSStatus OS9CreatePingSocket( EndpointRef* lpEndpoint )
{
OSStatus res;
OTConfigurationRef icmpConfRef;
icmpConfRef = OTCreateConfiguration( kRawIPName );
if ( icmpConfRef )
{
*lpEndpoint = OTOpenEndpointInContext ( icmpConfRef,
0, 0, &res, OTccp );
if ( res == kOTNoError )
{
res = OTBind( *lpEndpoint, nil, nil );
if ( res == kOTNoError )
{
OTSetNonBlocking( *lpEndpoint );
AddToLog( "\pPing endpoint created" );
}
else OTCloseProvider( *lpEndpoint );
}
else OTDestroyConfiguration( icmpConfRef );
}
else AddToLog( "\pOTCreateConfiguration returned zero" );
return res;
}
I check the returned value - it is OK.
This function is called from MPTask, that runs in the loop.
After that, in this loop I call this function in response to a message
from my primary thread.
struct MY_PING
{
UInt8 Type;
UInt8 Code;
UInt16 Checksum;
UInt16 id;
UInt16 SeqNum;
OTTimeStamp Timestamp;
};
typedef struct MY_PING MY_PING;
OSStatus OS9Ping( EndpointRef ep, unsigned long ulIP, OTTimeStamp*
lpTimestamp )
{
OSStatus res;
InetAddress dest_addr;
TUnitData tData;
MY_PING myPing;
OTInitInetAddress( &dest_addr, 0, ulIP );
myPing.Type = ICMP_ECHO;
myPing.Code = 0;
myPing.SeqNum = 1;
myPing.id = kOurMagic;
OTGetTimeStamp( &( myPing.Timestamp ) );
*lpTimestamp = myPing.Timestamp;
myPing.Checksum = 0;
myPing.Checksum = ChecksumBuffer( (UInt16 *)&myPing, sizeof( myPing )
);
MacZeroMemory( &tData, sizeof( tData ) );
tData.addr.len = sizeof( dest_addr );
tData.addr.buf = (unsigned char *) &dest_addr;
tData.udata.len = sizeof( myPing );
tData.udata.buf = (UInt8 *) &myPing;
res = OTSndUData( ep, &tData );
return res;
}
And my application crashes in the call to OTSndUData.
What can be the reason?
Regards,
Igor
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.