• 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: Efficiency in SmallSockets
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficiency in SmallSockets


  • Subject: Re: Efficiency in SmallSockets
  • From: Marco Binder <email@hidden>
  • Date: Tue, 17 Sep 2002 02:58:17 +0200

No need for the setEditable:YES and setEditable:NO. Might be responsible for some of the lag. also the scrolling after each newline might cause some delay at 20 line per second! You might be able to use an NSTimer to scroll down only every 0.5 seconds or whatever.

marco


Am Dienstag, 17.09.02 um 00:05 Uhr schrieb Anthony Duer:

Hi, I'm having a trouble with efficiency in SmallSockets. My problem occurs with a latency in when text arrives and the speed in which I can process it. Currently I'm developing a text-based game client which connects to a game server via a simple TCP/IP connection. My problem is that when I go to read from the socket, I first have to put the data from the socket into a NSData, read from the NSData into a NSString, then insert the NSString into a NSTextView. Under heavy load (10-20 lines/second) this seems to become very bogged down, taking a few seconds to 'catch up' to where the current status is. Here's my current working code, the function is run on a seperate Thread:

while([mySocket isConnected])
{
if([mySocket isReadable])
{
[mySocket readData: myData];
while([myData containsString: @"\n"])
{
line = [[NSString alloc] initWithData: [myData getBytesUpToString: @"\n"] encoding: NSUTF8StringEncoding];
[mainText setEditable: YES];
[mainText insertText: line];
[mainText setEditable: NO];
[line release];
[mainText moveToEndOfDocument:mainText];
[mainText scrollRangeToVisible:[mainText selectedRange]];
}
}
else
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
}
}

~Anthony Duer
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________


--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________ _______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Efficiency in SmallSockets (From: Anthony Duer <email@hidden>)

  • Prev by Date: Re: NSMatrix
  • Next by Date: Re: Dynamic Menu Items
  • Previous by thread: Efficiency in SmallSockets
  • Next by thread: Re: Efficiency in SmallSockets
  • Index(es):
    • Date
    • Thread