[comp.sys.mac.programmer] MacTCP question...

bitting-douglas@cs.yale.edu (Douglas Bitting) (04/06/91)

Hi.  I have a question... right now I am trying to write a simple little thing
with MacTCP.  Basically what I have done is translate the Pascal Code that
comes with the MacTCP toolkit for Hypercard to stand alone C code... however,
there is one part that isn't wuite working right (so far!) and I can't figure
out why.  Here is the code snippit in question:

int
CWorld::create_stream()
{
  	int i;
   
   connection = (tcp_connection_ptr) NewPtr (sizeof(tcp_connection_type));
   if (connection == NULL)
      return this->flagError("\pBuffer allocation failed");
   connection->magic = MAGIC_NUMBER;
   connection->incoming_size = 0;
   if ((i = OpenDriver("\p.IPP", &(sync_control_block.io_c_refnum))) != noErr) 
   {
      DisposPtr ((Ptr) connection);
      return this->flagError("\pDriver open failed");
   }
   this->zero_io_parms();
   this->put_control_long_at_offset ((long) &connection->buffer, (long) 32);
   this->put_control_long_at_offset ((long) TCP_BUFFER_SIZE,(long) 36);
   sync_control_block.cs_code = TCP_CS_CREATE;
>>>if ((i = PBControl (&sync_control_block, false)) != noErr) {
      DisposPtr ((Ptr) connection);
      return this->flagError("\pStream creation failed");
   }
   connection->async_control_block = sync_control_block;
}

Where the >>> is is where the code fails.  As far as I can tell, everything
works correcty up to there.  The Call to PBControl returns with an io_result of
-21 which is a bad io_c_refnum.  The io_c_refnum returned by OpenDriver is
always -49 (when I run it), and that is a little questionable only because it
is negative.

In case the above code doesn't make it clear, I am running THINK C (version
4.0.2) and using the TCL.

Any MacTCP gurus out there?  Any help would be greatly appreciated.  Please
respond by email to save net.bandwidth.

Thanks,
--Doug




-- 
Doug Bitting             | "And we know that in all things God works
PO Box 3043 Yale Station |  for the good of those who love him..."
New Haven, CT 06520      |                       --Romans 8:28
bitting@cs.yale.edu      +------------------------------------------