Help working with sockets, please

hi
i've managed to do some applications similar to chat programs, and i would like to know if my design is... acceptable
my problem used to be that any function trying to read data from a socket would block until it gets some data. if my applicacion is like a chat, i don't know when data is arriving.
so my solution is:
create a thread, which would be always reading the input stream from the socket. whenever it gets data, it send an event which listened by the main class, say, a JFrame.
so i created my own events, listener and listenermulticaster. well it works great but i wonder if there is another simpler way to do it.
another think that bothers me:
when i have my thread with my connected socket, and i want to shut the appz down, the only way i've found is to close the socket. the thread must be able to manage that, and afterwards, returns from run function.
well what do u think about all of this?? i would be very grateful for any opinion you tell me
thanks in advance

a reference to the thread, calls that method. the
socket is closed, the main loop breaks (i dont
remember now if an exception is thrown) and the thread
ends
i agree, i dont like this and it seems unreliable.
about the method interrupt, what is the diference from
retunrning from run method??
thanks very much for your help!!you will have a method that is reading from the Socket, it will block until some data is available
closing the Socket (one would hope) should cause that method to throw an Exception, you can use that Exception to exit the run() method, but if the Socket is closed from the other end, then it seems unreliable that the Exception is thrown, leavin the read method waiting for data that it can never recive
Thread.interrupt() will terminate all such blocking IO methods and you can use this also to exit the run() method
belt and braces maybe, but handy all the same

Similar Messages

  • My factory unlocked iphone 4s mms is not working with tmobile, please help...

    my factory unlocked iphone 4s mms is not working with tmobile, please help...

    Check out this link. It should fix the problem
    http://support.t-mobile.com/thread/17918?tstart=0

  • TS3276 I am not able to Mobile Me email account to connect with iCloud or my Apple Mail program. Don't know if my settings are correct or not. Can anyone help me with this please?

    I am not able to Mobile Me email account to connect with iCloud or my Apple Mail program. Don't know if my settings are correct or not. Can anyone help me with this please?

    http://support.apple.com/kb/HT5922
    If you want to mirror your desktop, see:
    http://support.apple.com/kb/HT5404
    Regards.

  • I have a brand new MacBookProo and I can not open PDF files from my desktop. Can anyone help me with this please?

    I have a brand new MacBookProo and I can not open PDF files from my desktop. Can anyone help me with this please?

    A new Mac comes with 90 days of free tech support from AppleCare.
    AppleCare: 1-800-275-2273

  • Can anyone help me with forms please

    -----------------------------------source.cfm--------------------------------------------
    <cfquery name="myquery" datasaource="mydatasource">
    select studentid
    from tbl_student
    </cfquery>
    <cfform action="reciever.cfm" method="post">
    <cfoutput query="myquery">
    <cfinput name="#myquery.studentid#" type="text">
    </cfoutput>
    </cfform>
    ------------------------------------reciever.cfm------------------------------------------ ----
    <cfquery name="myquery2" datasource="mydatasource">
    select studentid,studentname
    from tbl_student
    </cfquery>
    <cfoutput query="myquery2">
    <cfif #form.#myquery2.studentid## eq
    #myquery2.studentname#>
    Student Found
    </cfif>
    </cfoutput>
    anyone can know how to do this? i just want to make the
    #form.# dynamic because the id is coming from database
    but seems it is not allowed... anyone can help me with this
    please?or anyone know alternative solution for it?thanks in
    advance.

    thanks again cf_dev2...
    but the <cfinput> that i'm trying to use was dynamic
    because it can be a textbox or a radio button or a checkbox.. i got
    no problem in assigning their name now.. because i string
    concatinated them like placing their specific id from the database
    into their name,for example
    <cfquery name="choices" datasource="mydatasource">
    select choiceid,choicetype
    from tbl_choice
    </cfquery>
    <cfform name="source.cfm" method="post">
    <cfoutput query="choices">
    <cfset choicename='multiplechoice'>
    <cfset choicenamed = choicename.concat(#choiceid#)>
    <cfif #choices.choicetype# eq 'multiplechoice'>
    <cfinput type="radiobutton" name="#choicenamed#">
    </cfif>
    </cfoutput>
    </cfform>
    the problem now is the way how can i receive it and compare
    it on the answer values from the database for the choices.

  • HT5622 i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading

    i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading.
    <Phone Number Edited by Host>

    You aren't addressing anyone from Apple here.  This is a user forum.
    You might want to call a neaby Apple store to see if they have a free class you could attend.

  • Quicktime only works with iTunes - Please help!!!

    if I have iTunes installed on my computer with the quicktime, quicktime will not work when viewing videos that are sent to me via email or on places like myspace. It is just a white screen with a Q and a ? mark. What is causing this problem? In order to view those videos I have to uninstall quicktime and then to listent to my iTunes I have to reinstall it.

    Ok I've followed countless random post instructions, uninstalled and reinstalled both iTunes and Quicktime multiple times, cleaned the registry, temp files, documents and settings, program files, etc. and Quicktime 7 still crashes. What in the **** is the deal here? I have to believe that this is a problem with a straightforward solution. Quicktime used to work fine. There are only two possible problems here:
    1) Some remnant of an old Quicktime install is screwing me up. This should not be this hard to rectify, there are a finite number of places Quicktime puts files. Is there any folder I haven't checked?
    2) Some odd glitch allowed me to successfully run QT7 before but now, for whatever reason, my setup has changed in some way I'm not noticing and its now no longer working. In this case there still must be some solution since the problem is very specific: Works with directx disabled, doesn't with directx enabled.
    I sincerely appreciate these forums and everyone who takes the time to read them and help users like me. Still, am I missing some place where I can get a solid official answer from Apple on this? I paid for pro, and that doesn't even get me a support email address?

  • Can a 7232 work with 7100 PLEASE HELP!!!

    I have been having a ton of problems with my 6416 DVRs, after trips from Tech Support and multiple calls I finally ended up receiving a 7232 to replace 1 of the units.  That has helped quite a bit and then the 2nd 6416 continued to lag and pixelize so I finally got Verizon to send me a replacement.  The rep on the phone convinced me that getting a multi-room and set top for the house was the "right" option.  So a week later I receive the 7216 and 7100.  
    Come to find out the 7100 has no storage and the 7216 is only 150GB, whereas the 7232 has 320GB.  
    So my question is....
    Can I just keep the 7232 and the 7100 and will it work?  I have been trying to get it set up but I can't get the 7100 to function properly and tired of spending HOURS on the phone with Verizon trying to explain this mess.    

    LuAnnF wrote:
    I have been having a ton of problems with my 6416 DVRs, after trips from Tech Support and multiple calls I finally ended up receiving a 7232 to replace 1 of the units.  That has helped quite a bit and then the 2nd 6416 continued to lag and pixelize so I finally got Verizon to send me a replacement.  The rep on the phone convinced me that getting a multi-room and set top for the house was the "right" option.  So a week later I receive the 7216 and 7100.  
    Come to find out the 7100 has no storage and the 7216 is only 150GB, whereas the 7232 has 320GB.  
    So my question is....
    Can I just keep the 7232 and the 7100 and will it work?  I have been trying to get it set up but I can't get the 7100 to function properly and tired of spending HOURS on the phone with Verizon trying to explain this mess.    
    The QIP-7232 P2 should have a 500 gig drive, even though it says 32. Now the 7100 should have no issues working with the 7232 in a Multi Room configuration. But remember the 7100 only has pause and continue when viewing from recorded conted that is being played back fron the MRDVR 7232. The 7100 can not pause live content. I would send the 7160 back unless the 7232 is broken. The 7232 is a $40 upgrade if they make you pay for it.

  • Help me with net, please!!!

    I'm a beginner
    I have to learn java urgently... as fast as possible.
    So I need a little net. application which works with strings, url and have graphic interface?
    For example: a window with button, which on pushing get some information from one of the url and do something with this information. It doesn't matter...
    Have you smth for me???
    Please!!!

    public class TeachmeJava{
    boolean lazy = true;
    String solution="Study!!!!!";
    public static void main (String args){
    TeachmeJava j = new TeachmeJava();
    if (j.lazy){
    System.out,println(solution);
    Does this help? ;)
    Sorry for the typo. Too many custom tags lately :)

  • Improving the LabVIEW Help: Working with Data Types

    Have you ever had trouble figuring out how to work with the waveform data type, the dynamic data type, or some of the other more complex data types in LabVIEW? As a tech writer on the LabVIEW team, I'd like to improve our documentation about working with data. What would you like to see? What would be helpful? Have you ever given up on a particular data type because it didn't work? Have you ever created a replacement data type because you preferred not to use a LabVIEW data type?
    Lacy Klosterman Rohre | Marketing Editor | National Instruments | 512.683.6376 | ni.com/newsletter

    I've been programming LabVIEW since around 3.1 / 4.0.  Over the years and versions, I've found it necessary to approach a lot of the new datatypes and algorithms with some healthy skepticism because I don't think we're usually given a "fair and balanced" overview.  Some of the things that are highly promoted that bring "ease of use" for beginners (and I *do* understand the importance of that when you're growing your LabVIEW user base) can carry significant performance penalties that are mentioned in more of a whisper, if at all.  I'd just like a more full disclosure of the tradeoffs -- the good, the bad, and the ugly.
    Waveforms -- very rarely use them, unless required for analysis functions.  I have a vague notion (between a belief and a memory) that they used to carry a significant performance penalty compared to arrays, but that the gap is now much smaller.  Still, I'm most comfortable with my old habit of using data arrays.  Some of this came about because a lot of my work uses counters where I may have a variable "dt" value or where my AI is clocked by a counter and the "dt" isn't internally generated.
    Dynamic signals -- have never used them.  Have no clear idea what good they're supposed to be, and they seem to be tied in primarily with Express VI's, which I have also studiously avoided.
    Variants -- Use them only slightly.  Performance issues are a question mark.  Exception: have learned that the implementation of Variant properties allows their use as an efficient way to create associates for string lookup tables. 
    Digital Waveform -- have typically avoided it except when graphing digital data during debug.  Haven't found any compelling reasons to use it.  I do like the notion of a compress/expand capability for sparse digital data, but haven't exercised it enough to trust the implementation. 
    Recap:  I don't need more simple "how-to's" in the help.  I need a LOT more "why bother's" that include both pros and cons. 
    -Kevin P.

  • Help me with JARs PLEASE!!!!

    Hello,
    Following is the scenario
    Application name: PL
    Directory "PL" has
    - A.jar
    - B.jar
    When I create PL.jar I store it in the dir "PL" by using the appropriate relative path to A.jar and B.jar in the manifest file. PL.jar executes in folder "PL"; BUT when I copy PL.jar to another folder say desktop it gives me a NoClassDefFoundError. Can anybody help me with this as I have wrecjed my brains over this for 2 days. I have to distribute PL.jar to clients for testing purpose.....Please reply ASAP.
    Thanks.
    Salil.

    set (class) path or use package if its inside your dir.
    Message was edited by:
    deAppel

  • Suddenly my music videos won't play on my iPad. I just get the audio? Can anyone help me with this please?

    SUddenly my music videos won't play on my ipad1. I just get the audio. Can anyone help with this please?

    Look in the Videos App and play them in there.

  • Will downloader helper work with 5 or should I wait to upgrade to 5

    As I use Download Helper frequently will it work with Firefox 5 if I upgrade to V5 now or should I wait to download V5 at a later date?
    Thank you,
    Chad

    Download helper is working fine on version 5 firefox, and it's just updated itself

  • How about a little help working with Gbps Ethernet I/O (embedded and instantiated) and the Zynq SoC?

    A new Xilinx TechTip gives you some basics for working with the embedded Gbps Ethernet ports on all Zynq SoCs. This TechTip also applies to additional Gbps Ethernet ports you might instantiate in the Zynq SoC’s programmable logic. (More than one, if you like.) If you’re not familiar with basic Ethernet tools including the Wireshark protocol analyzer and the NetPerf benchmarking utility for Linux, give this one a read.
     

    kglad wrote:
    that code should be attached to the first keyframe that contains your flvplayback component.
    if you have more than one, you'll need to assign each a different instance name and adjust the code accordingly.
    the trace() should be added to your button listener function (openurl).
    All right, I think its going to be easy to explain if you please check my image here http://thenewmediastudio.com/roland/example.png
    I'm placing the code in the first frame, however, the movie is located in the 2nd frame but is not working, not sure where exactly I should place the code.
    And sorry but, that other thing about the trace, didn't understood that one.
    Thanks so much!

  • Help: Working with .MOV files in FCP and forced to RENDER FOR EVERY EDIT

    I'm working with .MOV files from my digital camera in Final Cut Pro and every time I make a new edit, I have to render it in order to see it in the canvas.
    How do I make it so that I don't have to render every edit in order to see it?
    (I've worked with files straight from a DV camera, and editing went fine. I'm assuming it has to do with the .MOV files)

    DV Cameras are not the same thing as a Digital camera. Digital cameras offer video on a limited basis and it's usually highly compressed in a non-editing format such as MPEG-2 or similar. NLEs are made to work with video cameras, not still cameras which is why you're having trouble.
    That's not to say you can't edit video captured with a digital camera, but you need to know how to prep it for editing. Some digital cameras shoot at odd frame rates and they all use some form of compression that is not typically used in editing. This means that you'll likely need to convert your clips to an editable format first using Compressor.
    Andy

Maybe you are looking for