[comp.sys.mac.programmer] Using MacTCP from Think C Qs

cmcclary@bronze.ucs.indiana.edu (Charles McClary) (04/04/91)

Anybody have any suggestions, comments, and/or warnings for using MacTCP 
calls from Think C.  So far, when I make the call to OpenResolver, it 
returns -1.  The File DNR.c is included in the project.

Thanks,
Charlie

Charles McClary
Workstations Division
University Computing Services
Indiana University
cmcclary@bronze.ucs.indiana.edu

resnick@cogsci.uiuc.edu (Pete Resnick) (04/04/91)

cmcclary@bronze.ucs.indiana.edu (Charles McClary) writes:

>Anybody have any suggestions, comments, and/or warnings for using MacTCP 
>calls from Think C.  So far, when I make the call to OpenResolver, it 
>returns -1.  The File DNR.c is included in the project.

Change the OpenRFPerm to OpenResolver. For some reason, that solves the
problem. I don't know why.

Here is what to do to the MacTCP header files that are provided:

In MacTCPCommonTypes.h, change the "ifndef/include" definition to look
like this:

#ifndef _MacTypes_
#include <MacTypes.h>
#endif /* _MacTypes_ */

In UDPPB.h, comment out the word "pascal" in the declaration of
UDPNotifyProc so that it looks like this (THINK C doesn't like a
typedefed pascal funtion):

typedef /*pascal*/ void (*UDPNotifyProc) (
		StreamPtr udpStream, 
		unsigned short eventCode, 
		Ptr userDataPtr,
		struct ICMPReport *icmpMsg);

Do the same thing in TCPPB.h for TCPNotifyProc:

typedef /*pascal*/ void (*TCPNotifyProc) (
		StreamPtr tcpStream,
		unsigned short eventCode,
		Ptr userDataPtr,
		unsigned short terminReason,
		struct ICMPReport *icmpMsg);

You will not be able to use these typedefs in your own programs; they
are only to deal with other declarations in your header files. In your
code, declare your notify procs as 'pascal void whatever' with all of
the parameters as they are declare in the typedef.

That's all I have found so far, except that in my copy of TCPPB.h,
instead of the csCode for receive buffer return being TCPBfrReturn as
documented, it was TCPRcvBfrReturn. I changed it to TCPBfrReturn.

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

sfalken@caen.engin.umich.edu (Steve Falkenburg) (04/04/91)

In article <1991Apr3.212555.20476@bronze.ucs.indiana.edu>, cmcclary@bronze.ucs.indiana.edu (Charles McClary) writes:
> 
> Anybody have any suggestions, comments, and/or warnings for using MacTCP 
> calls from Think C.  So far, when I make the call to OpenResolver, it 
> returns -1.  The File DNR.c is included in the project.
> 
> Thanks,
> Charlie
> 

Change the #define's for the resolver commands at the beginning to long
defines (i.e. 0L instead of 0).  This should solve part of your problems.

Also, you'll need to change all the occurences of "int" to "long" and
remove typedef'd pascal functions (not supported in LSC).  Otherwise
_most_ things in MacTCP work.  They should have done a better job with
this, and hopefully, they'll fix it so it works out of the box in 1.1.

-Steve Falkenburg

----------------------------------------------------------------------
Steve Falkenburg (sfalken@mondo.engin.umich.edu)   | Great pate', but
Macintosh Programming/Support                      | I've gotta motor!
Computer Aided Engineering Network, U of Michigan  |  -Heathers

rainer@hwsw.gedas.de (Rainer Raupach) (04/05/91)

I'm just interested:
Where can I find information about MacTCP?

Rgds Rainer

-- 
---
Rainer Raupach		Internet: rainer@hwsw.gedas.de
Network Coordinator	X.400:	S=RAUPACH C=DE A=DBP P=VW-GEDAS
VW-GEDAS Berlin, GER 	Phone:	+49 30 39007-629  / FAX : ext -999