Local Connection
Local Connection
- Subject: Local Connection
- From: Michael Paluszek <email@hidden>
- Date: Fri, 29 Mar 2002 07:16:21 -0500
I have a server application on the same machine as two client applications.
The server listens on port 5000 and then makes a connection on another port.
The two clients use identical OpenTransport code. The first client connects
but the second gets an error when it tries to bind of -3150 which is a bad
address error. If I make SocketSifter (a shareware application from
www.ekimsw.com) the second client SocketSifter connects without a problem
and the server transfers data to SocketSifter.) It seems that there is a
problem with my client code. I've synopsized it below (leaving out my code
that returns the error codes. The first error is with the bind.) Does anyone
have any suggestions on what I am doing wrong?
Sincerely,
Mike
Boolean SetupSend( int k, char target[] )
{
TEndpointInfo info;
TBind req, ret;
TCall sndcall;
OSStatus err = kOTNoError;
long bytes = 0;
OTFlags flags = 0;
OTResult lookResult;
InetAddress targetAddr;
long targetPort = 5000;
// The identity number for the endpoint
endpointInfo = new EndpointInfo;
endpointInfo->endpointID = k;
// Now create a socket
endpoint[k] = OTOpenEndpointInContext(OTCreateConfiguration(kTCPName),
0, &info, &err, NULL);
// Make it synchronous to set up the connection
err = endpoint[k]->SetSynchronous();
// Install notifier we're going to use
OTNotifyUPP theHandler = NewOTNotifyUPP(EventHandler);
err = endpoint[k]->InstallNotifier(theHandler, endpointInfo);
// Try to bind
InetInterfaceInfo localInternetInfo;
err = OTInetGetInterfaceInfo( &localInternetInfo, 0 );
OTMemzero( &reqsin, sizeof(InetAddress) );
OTInitInetAddress( &reqsin, (InetPort)thePort,
localInternetInfo.fAddress );
OTMemzero( &req, sizeof(TBind) );
req.addr.len = sizeof(InetAddress);
req.addr.buf = (unsigned char *) &reqsin;
req.qlen = 2;
OTMemzero( &ret, sizeof(TBind) );
OTMemzero( &retsin, sizeof(InetAddress) );
ret.addr.maxlen = sizeof(InetAddress);
ret.addr.buf = (unsigned char *) &retsin;
// Bind TCP to current address and port
err = endpoint[k]->Bind( &req, &ret );
-------
Michael A. Paluszek
Princeton Satellite Systems, Inc.
33 Witherspoon Street
Princeton, New Jersey 08542-3207
USA
Telephone: (609) 279-9606
Fax: (609) 279-9607
URL:
http://www.psatellite.com
_______________________________________________
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.