new JAVA Problem

Discussion in 'Software' started by e_f_w_a, Sep 20, 2004.

  1. e_f_w_a

    e_f_w_a Private E-2

    first , thanks to rmStar-R , problem solved :)
    and my new problem is Sockets... i'm using the method in.readLine() to read a line , if i do it too much , it's stuck . i can't find out when i recieve data and when i'm not . btw , i'm trying to build an IRC client , that means i'll be needing to do a lot of automatic reading ... any ideas?...
     
  2. e_f_w_a

    e_f_w_a Private E-2

    while (in.ready()) { <read> }
    that solved my previous problem... now , i got some more...

    ======1======

    during input stream , i'm trying to compare :
    if (gettok(xInString,18,18,32).toLowerCase().equals("pong"))
    in order to send the pong...
    never work , even though the String gettok(xInString,18,18,32).toLowerCase() is pong exactly . what's the problem here?

    ======2======

    i've used thread to maintain the reading on the server .
    when i disconnect :
    in.close(); // closing my input stream
    out.close(); // closing my output stream
    socket.close(); // closing the socket

    and then i try to connect (activating the thread):
    runner.start();

    and it's not working , not connecting!!! what is wrong?! :(
     
  3. rmStar-R

    rmStar-R Private E-2

    general rules for programming

    ======PROBLEM 1======

    I think this is the problem with standard java structure. java always creates a temporary objects as it calls for functions and operators. it may be the problem of cascaded application of methods.

    I don't know if it were really the problem but i suggest the following architecture
    for easy memory/object management:
    1.) save the input string to a variable say String inputString (this is just as what you did)
    2.) create a function boolean goodInput( String, int, int, int ) that returns true if the
    input string is valid and false otherwise. this step is different from your architecture above. further, the arguments of the function may also be different depending on the need.
    3.) use the function in (2) above as follows:

    if( goodInput( inputString, 18, 18, 32 ) ){ //or whatever appropriate arguments
    //groom or modify inputString as needed
    // such as inputString = inputString.toLower();

    if( inputString.equals( "keyString" ) ){
    //note: in your sample above, "keyString".equals( "pong" )
    //add something in here..
    }

    }

    there are other possible good solutions though. i just don't see the entire view of your project so i don't know which one is the best. ;)

    ======PROBLEM 2======

    the streams in, out, and socket may not being re-openned in the method .start() of runner object. just make sure that they already exists before start() is called and that they are closed.

    as a general rule programs have to be designed to either optimize:
    a.) SPEED -- we want our programs running fastest for a given job/service
    b.) MEMORY -- we our programs use the least amount of machine or random-access memory in any case, prioritizing speed over memory would mean a lot of memory requirements; on the other hand, memory over speed would really mean SLOW processes. normally, we do want to be just right in between. your programs should be designed to keep it in the middle and you have to ask your client which should it SLIGHTLY be: speed or memory.

    good luck to your work! hope these answers could give you enough hints to solve your problems.

    ---
    rm * -Rf
     
  4. e_f_w_a

    e_f_w_a Private E-2

    rmStar-R - genius :)
    problems solved , now something else...
    my font... don't change , i tried viewing other applets (basic applets) on my PC and they also showed no difference when i tried to change font (there was an option to change the font on the applet itself) .
    and my code :

    Font windowFont = new Font("Serif",Font.PLAIN,12); //1 inside > public void init()
    serverSelection.setFont(windowFont); //2 inside > public void init()

    what's the problem?
     
  5. rmStar-R

    rmStar-R Private E-2

    I'm glad your previous problems are now solved.

    Your last problem is tougher since i really don't know what is happening about fonts. But i have a question here:

    Does "serif" font type exists in your database?

    Try running your applets in different computer and see what happens. Ooops! hahaha!

    Good luck!
     
  6. e_f_w_a

    e_f_w_a Private E-2

    yes it does . the font exists on my PC for sure...
    btw , the selection is a Choice , not the drawstring type .
    and another problem i discovered is that my java can't connect to another online IRC server (all my testings were to connect to myself and they worked absolutely fine...) , with the message :
    access denied (java.net.SocketPermission <serverip>:<serverport> connect,resolve)

    <serverip> = server IP
    <serverport> = server PORT
    why is that?
     
  7. rmStar-R

    rmStar-R Private E-2

    Is it possible that Java has to load the font directory or something first for the java to "see" it? I don't know. just storming ideas. :(

    with respect to your "access denied" thing:
    is your computer allowed by the IRC? probably your trying to access using the wrong port. or probably no authentication yet.

    sorry, i'm getting less and less ideas about your problem. let's hope somebody out here, knows this, ok?

    good luck!

    try reading something about tcp connections and irc connections.
     
  8. e_f_w_a

    e_f_w_a Private E-2

    i'm sure about the details (port & address) , and i have no firewall blocking . it's something else , perhaps digital signature... i believe that the problem is security , java security... so i need digital signature or whatever it is .
    how can i add a digital signature? (not versign or something that includes payment)
     
  9. e_f_w_a

    e_f_w_a Private E-2

    now i'm pretty sure it's a policy thing . have any idea?...
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds