home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20776 < prev    next >
Encoding:
Text File  |  1993-01-06  |  4.0 KB  |  98 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!munnari.oz.au!newsroom.utas.edu.au!tasman.cc.utas.edu.au!justin
  3. From: justin@tasman.cc.utas.edu.au (Justin Ridge)
  4. Subject: ADSP prob: dspOpen gives errState! hints? (Q)
  5. Message-ID: <justin.726314554@tasman>
  6. Sender: news@newsroom.utas.edu.au
  7. Organization: University of Tasmania, Australia.
  8. Date: Wed, 6 Jan 1993 10:02:34 GMT
  9. Lines: 87
  10.  
  11. Hi once more to comp.sys.mac.programmers.
  12. First, I'd like to thank those who responded to my previous questions
  13. concerning INITs and MacTCP -- thankfully, the problems have been solved.
  14.  
  15. Now to the point of this posting.  I am trying to write a client
  16. application that will communicate with a server application on another Mac,
  17. via an AppleTalk network, using ADSP in THINK C.  However, I cannot get a
  18. local socket to issue an open request (dspOpen).
  19.  
  20. To get myself started, I have based my routines on those in IM VI, pp.32-48
  21. to 32-55.  The server uses the connection listener code, and the client
  22. attempts to connect to it using the myADSP routine.
  23. Here is briefly what happens:
  24. * The server application starts up fine.  It registers its socket name
  25.   perfectly, and goes into a loop waiting for open requests to it.
  26.   I have used CheckNET to verify that the socket exists & can be seen etc.
  27. * The client application starts up and will also register ITS name.  Again,
  28.   I have verified this using CheckNET, and by examining the error codes
  29.   returned from the calls.
  30. * The client itself can see the server's socket.  After calling PLookupName()
  31.   the numGotten field is set to one (1), indicating that the server was
  32.   located.
  33. * As far as I can tell, I am then extracting the server's correct address.
  34. * HOWEVER, when I build a control block and open a connection to that server,
  35.   I get an error of -1278: "Bad connection state for this operation."
  36.  
  37. A relevant section of code is shown below.  Hope I haven't missed any info..
  38. Can anybody suggest what is wrong with my script?  My guess is I am missing
  39. some fields out of the control block, but I cannot tell which ones.
  40. Has anyone else had experience with ADSP that can give some advice or even
  41. simple routines by way of examples?
  42.  
  43. Thanks in advance for any pointers.  Please send your replies by MAIL
  44. if possible, as I only get to read news like this infrequently.
  45.  
  46. ~~~~~
  47. NBPSetEntity(&server, srvrName, srvrType, srvrZone);
  48. /* form server entity record */
  49. /* srvrName, srvrType, srvrZone = pascal string constants */
  50. /* server is of type NamesTableEntry */
  51.        
  52. (*myMPPPBPtr).NBPinterval = 7;
  53. (*myMPPPBPtr).NBPcount = 3;
  54. (*myMPPPBPtr).NBPentityPtr = &server;
  55. (*myMPPPBPtr).NBPretBuffPtr = myData2ReadPtr;
  56. (*myMPPPBPtr).NBPretBuffSize = myDataSize;
  57. (*myMPPPBPtr).NBPmaxToGet = 1;
  58. (*myMPPPBPtr).NBPverifyFlag = 0;
  59.         
  60. /* get the list of servers matching these criterion */
  61. if ((myErr = PLookupName(myMPPPBPtr, true)) != noErr)
  62.         DoErr(myErr);
  63.  
  64. /* see if the desired server is in the list - ie. list !empty */
  65. /* myAddrBlk is of type AddrBlock */
  66. if ((myErr = NBPExtract(myData2ReadPtr, (*myMPPPBPtr).NBPnumGotten, 1, myEntity,
  67.                          &myAddrBlk)) != noErr)
  68.          DoErr(myErr);
  69.                 
  70. (*myDSPPBPtr).ioCRefNum = drvrRefNum;
  71. (*myDSPPBPtr).csCode = dspOpen;
  72. (*myDSPPBPtr).ccbRefNum = connRefNum;
  73. (*myDSPPBPtr).u.openParams.remoteAddress = myAddrBlk;
  74. (*myDSPPBPtr).u.openParams.filterAddress = myAddrBlk;
  75. (*myDSPPBPtr).u.openParams.ocMode = ocRequest;
  76. (*myDSPPBPtr).u.openParams.ocInterval = 0;
  77. (*myDSPPBPtr).u.openParams.ocMaximum = 0;
  78.         
  79. /* open a connection */
  80. if ((myErr = PBControl(myDSPPBPtr, false)) != noErr)
  81.         DoErr(myErr);
  82. ~~~~
  83.  
  84. PS. I have looked on ftp.apple.com & sumex for examples, or tips in old
  85. copies of Develop & tn's, but wasn't able to come up with anything.
  86.  
  87. Best regards,
  88. Justin Ridge.
  89.  
  90. --------------------------------------------------------------------------
  91. Justin Ridge,             |    Phone:  +61 02 202811
  92. Computing Centre          |    Fax  :  +61 02 231772
  93. University of Tasmania    |    Email:  Justin.Ridge@cc.utas.edu.au
  94. --------------------------------------------------------------------------
  95.  
  96.  
  97.  
  98.