• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TCP/IP connection via Ethernet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TCP/IP connection via Ethernet


  • Subject: Re: TCP/IP connection via Ethernet
  • From: Igor garnov <email@hidden>
  • Date: Sat, 13 Mar 2004 23:19:18 +0300

On Friday, Mar 12, 2004, at 17:40 Europe/Moscow, Livio wrote:

Igor garnov wrote:


On Thursday, Mar 11, 2004, at 15:51 Europe/Moscow, Livio wrote:

I need to make a TCP/IP connection between two Macs via Ethernet (using the first as client and the second as server), is it >>> possible?

Then I have an application that opens an endpoint, binds it to the local address (192.168.1.1) and finally tries to connect to the second computer's address (192.168.1.2). It always returns with a T_DISCONNECT event with error 61 in the reason field of the TDiscon record.

On the second computer I have the same application listening for the traffic.

Can anybody tell me what'is wrong (or/and what id missing)?


If you try to connect and your notifier callback is called with T_DISCONNECT, and the error is 61 - this means that no application is listening on the destination port on the remote machine.

Apparently, there is something wrong with the code responsible for listening to the incoming connection requests, or you specify a wrong port number in your OTConnect call.

Yes, you're certainly right about port numbers. The fact is that I'm absolutely not sure of my method of using them!

I strongly believe that if you want to establish a TCP/IP connection, you should not bother yourself with Ethernet-related things.

Try the following code:

OTClientContextPtr OTccp = 0;
InetSvcRef inetSrvRef = 0;
OTConfigurationRef otConf = 0;
OTNotifyUPP myOTNotifier = 0;

if ( InitOpenTransportInContext( kInitOTForApplicationMask, &OTccp ) == kOTNoError )
{
inetSrvRef = OTOpenInternetServicesInContext( kDefaultInternetServicesPath, 0, &status, OTccp );
myOTNotifier = NewOTNotifyUPP( OTCallback );
otConf = OTCreateConfiguration( kTCPName );
if ( otConf )
{
status = OTAsyncOpenEndpointInContext ( otConf, 0, 0, myOTNotifier, 0, OTccp );
}
}

void pascal OTRevealerCallback ( void* pContext, OTEventCode code, OTResult result, void* lpCookie )
{
TCall sndCall;
OSStatus status = 0;
InetPort iPort;
InetAddress dest_addr;
TDiscon tDisconnect;

switch ( code )
{
case T_OPENCOMPLETE:
if ( lpCookie )
{
myEP = (EndpointRef) lpCookie;

OTSetAsynchronous( myEP );
OTSetBlocking( myEP );
OTInstallNotifier( myEP, myOTNotifier, myEP );

status = OTBind( myEP, nil, nil );
if ( status != kOTNoError )
{
/* error binding */
}
}
else
{
/* error opening */
}
break;
case T_BINDCOMPLETE:
/* the endpoint has been bound; I can connect it */
OTInitInetAddress( &dest_addr, iPort, ulIP );

MacZeroMemory( &sndCall, sizeof( sndCall ) );
sndCall.addr.buf = (UInt8 *) &dest_addr;
sndCall.addr.len = sizeof( dest_addr );

status = OTConnect( (EndpointRef)pContext, &sndCall, nil );
if ( status != kOTNoDataErr )
{
/* error trying to connect */
}
break;
case T_CONNECT:
/* the other party has accepted my connection request */
break;
case T_DISCONNECT:
/* connection is refused */
MacZeroMemory( &tDisconnect, sizeof( tDisconnect ) );
OTRcvDisconnect( (EndpointRef)pContext, &tDisconnect );
break;
}
}

This is Carbon code - I suddenly realized that your code may be classic. However, I hope the above will help you.

Unfortunately, I could not understand your code. That's why I am making no suggestion regarding how you could modify your code to make it work.

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.


  • Prev by Date: Calling MPNotifyQueue from OT notifier
  • Next by Date: Re: Calling MPNotifyQueue from OT notifier
  • Previous by thread: Re: TCP/IP connection via Ethernet
  • Next by thread: is proxy activate
  • Index(es):
    • Date
    • Thread