Is there a way to make an event handler to watch for inbound socket action?

So I have a program that I've put on hold till spring break: Its a simple TCP/IP chat program for MUDs or IRC servers. Now its time to get this monkey running.
Right now I have a problem where it locks up after initiating the connection to release after the server disconnects on it's side. I've tried futzing with threads but that was too complicated for this problem. If I could just have it act like an event where it spits out the info received from the IRC/MUD server, that would be ideal.
Any suggestions?
PS: In the past I tried posting my code but no one here seemed to understand what I was trying to do.
CodeDragon

There's nothing built-in to do what you want. I looked at the code from your old posting and I see two potential problems with yoru read code.
1. I'm not sure why are you using the "in.reset()"... I doubt that's the cause, but I don't think you need it.
2. I think your loop is incorrect. Your loop will keep reading until the Reader hits the EOF--which is a server disconnect in this case.
What you want is something like:
boolean eof = false;
while(in.ready() && !eof) {
   String line = in.readLine();
   if(line!=null) {
      scroll.append(line);
      scroll.append('\n');
   } else {
      eof = true;
}If you wanted to make this asynchronous, use your old loop, but push the lines out to a queue of some sort...somethign like:
java.util.BlockingQueue <String>queue = new BlockingQueue<String>();
Runnable r = new Runnable() {
public void run() {
   String line = null;
   while( (line = in.readLine()) != null) {
     queue.put(line);
   queue.put(null); //tells your loop to abort
Thread t = new Thread(r);
t.start();
String line = null;
while( (line = queue.take()) !=null) {
   System.out.println(line);
}Edited by: James_Schek on Mar 20, 2008 4:50 PM

Similar Messages

  • Is there a way to make the bluetooth source I pick for Siri persistent?

    I have my iPhone paired with the factory Bluetooth hands-free audio in a car. I like using it for phone calls, but not for Siri.
    When I start Siri, I can choose my audio source, but the iPhone forgets the selection after that session, and defaults back to trying to use the car's speaker and mic the next time I use Siri.
    Is there a way to make this audio source selection persistent?
    Thanks,
    Heath

    Hey,
    I'm a Quadriplegic and I use my iPad with a mouthstick I made. Everything works great. Send me an email to bradcletter AT gmail.com and I'll help you out with everything!

  • Is there a way to "throw" the event handling task

    I want to create a ButtonPanel class (extends JPanel), and this ButtonPanel class will add 3 buttons to it (in a GridLayout). But I don't want this ButtonPanel to control the event handling for these buttons, I want the JFrame or whatever container above the ButtonPanel to be controlling the ActionListener for the buttons. If I do this
    button1.addActionListener(this)is there a way for me make the ButtonPanel pass the ActionPerformed() task to the container above it?
    or better yet what should the "?" be in this statement?
    button1.addActionListener(?)so that the ActionListener (the one doing the actionPerformed) will always be the container containing the ButtonPanel. Thanks...Happy Thanksgiving.

    Well.. I can't be sure this is "good design", but this is how I usually do it, and it works well for me, for a few reasons.
    1. The ButtonPanel is accepting an ActionListener (an abstract interface) instead of a contrete class such as a JFrame or the actual class. This move allows the Panel to be re-used in similar situations as long as there is something to handle the button's events.
    2. The JFrame is the best candidate to handle the event since it holds the other components that this button click is suppose to manipulate. Of course if there are other components more suitable, I would make it implement the ActionListener instead of the JFrame itself.
    Of course there are many other ways to do this, such as using an anonymous inner class, but that won't work in your case since you want the parent Frame to handle the event. I would like to learn about other good methods of achieving this as well!

  • Is there a way to make " focus on content " as default for all pages?

    I am trying to remove the left navigation pane on my sharepoint site. Even if I am able to modify the master page and make the "DeltaPlaceHolderLeftNavBar" property as invisible, there is some extra space that appears on the left hand side of
    the page. However, when I click on the "focus on content" button, it seems to hide the left empty space and the page title. I would want to set this as the default view for my page. Is there a way to do this?

    Hi Verma,
    I wouldn't go so far as to say your method of commenting that Script Block is incorrect, however you can more easily just add the following CSS to a script editor web part. The key to solving your issue with the left side space is the addition of the margin
    rule for .ms-fullscreenmode #contentBox:
    <style type="text/css">
    #sideNavBox {
    display: none;
    #contentBox {
    margin-left: 0px;
    .ms-fullscreenmode #contentBox
    margin-left: 0;
    </style>
    If you would like to also hide the "Show All Content" button altogether you could use the following JavaScript:
    <script language=”javascript”>
    _spBodyOnLoadFunctionNames.push(“HideBrandingsuite”);
    function HideBrandingsuite()
    document.getElementById(‘ctl00_fullscreenmodeBtn‘).style.visibility = ‘hidden’;
    </script>
    Keith Tuomi | Twitter: @itgroove_keith | Blog:
    http://yalla.itgroove.net
    Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

  • Outside of zoom, is there a way to make the text under icons larger for elderly use of iPad?

    We gave my mom an ipad mini, but the text under the icons is barely readable for the elderly.  The accessibility options increase the size of contacts, email, etc, and the zoom gives an option to increase, but that is not user friendly for the elderly - 3 finger tap on/off??? Really????  For a senior with arthritis?
    Does anyone know a way to increase the size of the text of the icons on the ipad? 
    Thanks for any insights.

    Try After Effects, it's perfect for keying stroke and all text characteristics.
    Here's an example

  • Is there a way to make fillable forms iPad aware?

    I'm creating fillable forms, in Adobe Acrobat Pro 9, for medical professionals who are having their patients fill them out on iPads using the PDF Expert app. Is there a way to make the forms iPad aware?
    For example, when you enter an event in your iPad or iPhone calander there's that wheel where you can choose the date. I want that wheel to show up when patients are filling out a date on their forms.
    I know that you can alter the PDF form to extend to Reader so is there a way to do something similar with PDF Expert? Or is that not a possiblity yet?

    There are a number of apps for the iPad/iPhone/eReaders/tablets that can process Acrobat forms but not LiveCycle Desiger forms. Adobe has Adobe Reader X for mobile.
    There are links for develpers on that page.
    Have you tried contacting the PDF Expert developers?

  • In contacts there is the possibility to add a new event, as the birthdays, but they do not appear in iCal. Is there any way to make that possible? It is normal to have a person with his birthday, anniversary and others key dates you want to link to him.

    In contacts there is the possibility to add a new event, as the birthdays, but they do not appear in iCal. Is there any way to make that possible? It is normal to have a person with his birthday, anniversary and others key dates you want to link to such person, but the only one shows up is the birthday. How to be able to show all those dates linked to people in the agenda in the iCal?
    Thanks

    Hi,
    I sugggest you try my application, Dates to iCal. It is shareware with a 2 week trial period.
    Dates to iCal 2 is a replacement for Apple's birthday calendar for iCal. It has a range of features to allow the user to choose what, and what not, to sync to iCal from Address Book.
    As well as automatically syncing birthday dates from Address Book, Dates to iCal 2 can sync anniversary and custom dates. It can set up to five alarms for each date in iCal and can also set different alarms for birthdays and anniversaries. It allows the option of only syncing from one Address Book group. This application also allows for the titles of the events sent to iCal to be modified to the user's preference.
    Best wishes
    John M
    As I sell software on my site and ask for donations, the Apple Support Communities Use Agreement requires that I state that I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Is there a way to make a smart "playlist" of specific books in my iTunes library, and copy ONLY THOSE books to an iOS device? I own an iPad and an iPhone but I want different books on different devices.

    Is there a way to make a smart "playlist" of specific books in my iTunes library, and copy ONLY THOSE books to an iOS device? I own an iPad and an iPhone but I want different books on each different device. When I've tried this, the iOS devices don't seem to respond.

    There is no playlist for iBooks, butther eis nothing to preent you from choosing to download specific titles from itunes, or syncing just specific titles to an individual device.

  • Is there a way to make all page margins the same?

    I've exported a book file from indesign. Since the pages were in a book-type spread, the odd and even pages have different margins. The odd page has the bigger margin on the left, while the even has the bigger margin on the right.  Is there any way to make these identical after the fact. I can't go back and redo the indesign file.

    Thanks, there are 382 pages. Can't do them one by one.  And I purposely made the margins different in indesign, to give people more space in the middle.  The margins are as follows:
    But when I try to reverse the inside outside on one page of the spread, just reverse them, so the dimensions are the SAME, all the text and photos move.

  • Is there a way to make sure my MBP doesn't use a particular resolution or ?

    This may be a stupid question. I am hooking my MBP to my lcd tv. When I first connected the television, my tv displayed the message "mode not supported". Having played a little at this I simply went to my display preferences and looked at what resolution was running to my tv. (I have my display preferences in the toolbar) It was running 1920x1080 at 60Hz and right above that there was another 1920x1080 at 60Hz so I clicked on that and my external display lit right up. (Turns out the second resolution's refresh rate is actually 59.9Hz) So no problem right? Well I use this set up as sort of a media center so I like to run my MBP with its lid closed. When I close the lid, and rewake the MBP, my television gives me the message "mode not supported". So there is a signal but the tv can't display it. This leads me to believe that when I close the lid on my MBP it decides to run at the 60Hz as opposed to the functional 59.9Hz. The problem is I can't see the display to change the resolution or refresh rate. Is there a way to make sure my MBP doesn't use a particular resolution or refresh rate? I have tried changing it before I close the lid. I have tried it in mirrored display mode. Nothing works so far. Please Help!

    Not really. In the Displays preferences you can only check the option to show supported resolutions, but that only will be present with another display connected (I believe.) On laptops it isn't an option, obviously, but it may be present once you connect an external display.
    You might try using the shareware utility SwitchResX - VersionTracker or MacUpdate.

  • Is there any way to make the sent folder in mail list emails "to" instead of  "from"

    Is there any way to make the sent folder in mail list emails in the "to" order instead of  "from".

    Sure open Sent folder.
    Just above first message is an icon titled Sort By Date followed by a downward pointing arrow.
    Click on the arrow and select "To" from the list.
    Allan

  • Is there any way to make Mail open next message?

    Is there any way to make Mail open the next message on the inbox automatically after deleting, forwarding o saving a message?
    I mean, is there any way to, after reading a message, going to the next or previous message without double clicking the main inbox window?
    I used (on windows) to read mail on outlook, or even on entourage for mac, and after I read a message, even if I deleted it, forward it, replied it, or even saving it on a folder, automatically the program (outlook, entourage, hotmail, etc) opened the next message on the inbox, but I am not able to find any way to make Mail do that.
    Is there a way to it? Or should I provide suggestions to Apple?
    By the way, no meant to prefer microsoft for this, I just think this is a cool feature for reading several messages one after another without going back to the main inbox page and double clicking the message to read...
    Thanks for any help

    Down-arrow, Return. Return opens the selected message. I read through hundreds of messages without ever touching the mouse. Once you get used to the keystrokes, Mail is extremely efficient.

  • I share a photo stream with a family member. Is there a way to make it so we have separate photo stream but still use the same apple id?

    i share a photo stream with a family member. Is there a way to make it so we have separate photo stream but still use the same apple id?

    You'll want a separate iCloud account for each user in addition to the main Apple ID used for purchases.
    Let's say you have a family of four (husband, wife, and two children). Here is what you will need:
    Main Apple ID for shared purchases in Tunes (everybody will be using this)
    iCloud (Apple ID) account for husband
    iCloud (Apple ID) account for wife
    iCloud (Apple ID) account for child 1
    iCloud (Apple ID) account for child 2
    Yes, you can have both an Apple ID and iCloud account setup on the same device. On each iOS device, setup the main Apple ID account for the following services:
    iCloud (Photo Stream and Backup are the only items selected here).
    Music Home Sharing
    Video Home Sharing
    Photo Stream
    Additionally, on each iOS device, add a new iCloud account (Under Mail, Contacts, Calendar) that is unique to each user for the following services:
    Mail (if using @me.com)
    Contacts
    Calendars
    Reminders
    Bookmarks
    Notes
    Find My iPhone
    Messages
    Find Friends
    FaceTime
    On your individual Macs (or Mac accounts), use the main Apple ID in iTunes. Then, use the unique iCloud account in/for iCloud.
    Now that everbody is using separate iCloud accounts for your contacts, calendars, and other things, it will be all be kept separate.
    The only thing that is now 'shared' would be iTunes content (apps and other purchases), backups via iCloud (if enabled), and Photo Stream (if enabled).

  • Iphone 4S newly updated to iOS8, keeps popping up window notifying me of things I turned off (cell usage, location, etc) to preserve battery life.  Is there any way to make them stop telling me every time I use the affected apps?

    I have finally taken the step of updating my iPhone 4S to iOS8 after learning the hard way last update to wait for the bugs to be worked out.  I was horrified to find that the battery was being sucked dry in no time at all.  After finding a great article posted elsewhere on the apple forums, I went through and turned off all unnecessary options involving the use of cell data, location services and background refreshing.  My battery life has thankfully returned to what it was before the update.  
    HOWEVER, now, every time I open an app for which I turned these things off, the window informing me of that pops up.   I am getting really irritated by this as I made all of these decisions deliberately and am well aware that I may need to go back and change them in order to activate certain capabilities when I want to use them.  I had done the same thing with the last iOS, but there were far fewer that needed to be turned off and the battery life seemed to be less affected by those that I left on so it was not the annoyance it has become now.
    Is there any way to make the phone stop presenting me with these idiot messages?   TIA

    Sorry no, there isn't a way to turn off those reminders.
    You can send Apple a feedback here  http://www.apple.com/feedback/

  • Is there a way to make Illustrator save in the background, like Photoshop?

    Out of Photoshop, InDesign and Illustrator, Illustrator is definitely the one I have most problems working with, due to small UI differences and ways of handling things
    Like the fact that you can't drag next to a number to change it, like in Photoshop. Or the fact that I can't sync my settings (it only says "Signed in as:", and when I press Manage Account, I'm taken to my CC files in Safari).
    But most annoying is the fact that whenever I'll save a document in Illustrator, a dialogue box opens letting me know the progress of the saving. Not only does this make me unable to continue working on the document (if the file is large, it takes some time), the app icon starts jumping in the dock if I switch to another program before the box appears.
    So, is there any way to make it save in the background, like in Photoshop? I'm running OS X, with Illustrator version 17.1.0.

    This really frustrates me, small differences between the apps that shouldn't be there.
    I understand you can't change the keyboard shortcuts to be the same/similar, but this is totally different. Let's hope it changes soon.

Maybe you are looking for

  • Fixed Assets - Tax Book Depreciation Reset

    Hello Fixed Assets Experts, My company recently reorganized our parent company, and now has the following scenario: Due to legal changes, we need to start over the useful life on our tax books (10 and 11) and restart the calculation of depreciation b

  • Wpa enterprise help

    I have a MacBook, that is running leopard. I am having trouble connecting to my schools wpa enterprise wireless. I am regestered to access the wireless, but am having trouble connecting. I think my problem is that i dont know how to tell the computer

  • Link "OrgChart" in Who's Who

    In Who's Who (web dynpro version for ERP2004), I want to display Organizational Unit in an employee's detail and I have customized the tables V_T7XSSSERRES and V_T7XSSSERSRV. However the link don't work. If I click on Org Chart link, a new blank page

  • FRM-41003:  This function cannot be performed here.

    FRM-41003: This function cannot be performed here. Cause:     You tried to perform a function that references a table, but current block does not correspond to any table. Action:     No action is necessary. You cannot perform the requested function o

  • Help viewer crash

    Hi This has been posted eslewhere but I did not find any solution to my problem so here goe. I have tried to access the help files in safari and finder but they wont open or at least they briefly open then crash. I have tried all the tips seen on her