• 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: OpenTransport behaviour under X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OpenTransport behaviour under X


  • Subject: Re: OpenTransport behaviour under X
  • From: Mike Cohen <email@hidden>
  • Date: Thu, 6 Nov 2003 18:56:50 -0500

The select call is available natively in OSX, plus the standard unix socket calls are very similar to Winsock. Could you have it use the native socket layer? I'm sure the results would be a lot better than using yet another layer on top of OT, which itself is a layer on top of native sockets.

On Nov 6, 2003, at 5:42 PM, Marc Stibane wrote:

1. send next command to RIP
2. start calling OTLook in a loop
3. RIP answers
4. OTLook keeps returning 0 instead of T_DATA, so my app hangs in that
loop, never getting the answer.

For step 4, couldn't you set the endpoint non-blocking, then call OTRcv
in a loop until you've read as much data as you expect to get at that
point, then go back to blocking?

The problem is that the application was written for WinSocks, and calls
"select". The glue code uses OTLook to simulate the behaviour of "select"
- which doesn't want to read data, but only to find out whether new data
arrived.
Later the application calls "recv" to read that data.


int select(int ndfs, fd_set *readfds, fd_set *writefds, fd_set *exeptfds,
struct timeval *timeout) {
long millis;
int fd;
int rcnt=0, wcnt=0, ecnt=0, cnt;
static int timedout = 0;
UInt32 now = TickCount();
UInt32 expire = 0;

if (timeout) {
millis = timeout->tv_sec * 1000 + timeout->tv_usec/1000; // microseconds
// create timer task
//int selectTimerID = ::OTCreateTimerTask(selectTimer, &timedout);
// int selectTimerID = ::OTCreateTimerTask(0L, 0L);
// start timer
//OTScheduleTimerTask(selectTimerID, millis);
expire = now + (6*millis/100);
do {
size_t n = 0;
rcnt = wcnt = ecnt = 0;
for (fd = 0; fd < MAXFD && fd < ndfs; fd++) {
if (sockets[fd].ep != kOTInvalidEndpointRef) {
if (readfds && FD_ISSET(fd, readfds)) {
int state = myOTLook(sockets[fd].ep, false); // TODO this doesn't
work !!!
if (state & (T_ERROR|T_RESET|T_DISCONNECT|T_UDERR)) {
return -1;
}
if (state & T_DATA) {
rcnt++;
}
}
if (writefds && FD_ISSET(fd, writefds)) {
if (OTGetEndpointState(sockets[fd].ep) == T_DATAXFER) {
wcnt++;
}
}

if (exeptfds && FD_ISSET(fd, exeptfds)) {
/*
*/
}
}
}
if (rcnt || wcnt || ecnt) {
// kill timer
// OTCancelTimerTask(selectTimerID);
break;
}
// OTIdle();
now = TickCount();
} while (now <= expire && !timedout);
// kill timer
// OTDestroyTimerTask(selectTimerID);
timedout = 0; // reset for the next loop (it's "static")
} else {
// ParamText("\pselect called with timeout=nil!", nil, nil, nil);
// Alert(132, nil);
return -1;
}

if (rcnt) {
cnt = rcnt;
} else if (wcnt) {
cnt = wcnt;
} else if (ecnt) {
cnt = ecnt;
} else {
cnt = 0;
}
return cnt;
}


Marc Stibane
Fesh! email@hidden
Kurf|rstenstr. 154 tel +49-30-3990 2690
10785 Berlin, Germany mobil +49-173-6522 422


In a world without walls and fences,
who needs windows and gates?
_______________________________________________
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.



--
Mike Cohen
http://www.macmegasite.com/ * http://www.mc-development.com/ * http://www.worldbeatplanet.com/

Music is the weapon of the future - Fela
_______________________________________________
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.

  • Follow-Ups:
    • Re: OpenTransport behaviour under X
      • From: "Philip D. Wasson" <email@hidden>
References: 
 >Re: OpenTransport behaviour under X (From: Marc Stibane <email@hidden>)

  • Prev by Date: Re: OpenTransport behaviour under X
  • Next by Date: Re: Proxy Tunneling (via the HTTP CONNECT method)
  • Previous by thread: Re: OpenTransport behaviour under X
  • Next by thread: Re: OpenTransport behaviour under X
  • Index(es):
    • Date
    • Thread