Problem using sockets, etc.

Alrighty, well I'm building a very basic chat server using the tutorial from IBM, and when I got to compile it, I get the following (DOS capture):
Server.java:51: warning: [unchecked] unchecked call to put(K,V) as a member of t
he raw type java.util.Hashtable
outputStreams.put(s, dout);
^
.\ServerThread.java:27: cannot find symbol
symbol : class DataIntputStream
location: class ServerThread
DataInputStream din = new DataIntputStream(socket.getInputStream());
^
1 error
1 warning
Not sure what the first one means, and I'm none too sure how to correct the second one. Suggestions?

It is a warning you'll get from java 5 and up when you use plain Object types where you would need to use a generic type. Look up "generics" for a more detailed explanation.

Similar Messages

  • Producer Consumer Problem using sockets

    Hello,
    Can anybody help me how to implement the Producer Consumer Problem using java sockets? Or any resources you've, pls forward it to me
    Cheers.

    Neg wrote:
    You just tell me if there is any means to do it.Yes, Just use a fixed length ArrayBlockingQueue on either end (or both ends) Use offer() to offer more data and this will return false when the queue is full.
    Note: the use of a Socket is entirely optional.

  • Problem using sockets locally

    Hey,
    I'm writing a simple client/server app and I'm trying to test it on my local machine. Every time I try to connect to the server I get a ConnectException. I'm running Ubuntu Intrepid (which I suspect may have something to do with my problem).
    This is how I'm setting up the server (just to add, this is threaded):
    this.socket = new ServerSocket(TCP_SERVER_PORT);
    socket.accept(); //blah, blah, blahAnd this is how I'm trying to connect:
    this.socket = new Socket("127.0.0.1",TCP_SERVER_PORT);I have no idea why this fails! Any ideas?
    Cheers,
    Puff

    ejp wrote:
    I get a ConnectExceptionwith what message?I get:
    java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:519)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:180)
         at client.TCPClient.<init>(TCPClient.java:30)
         at client.TCPClient.main(TCPClient.java:74)
    socket.accept(); //blah, blah, blahYou mean Socket client = socket.accept();That is what I mean, sorry (lazyness! :)).
    And this is how I'm trying to connect:
    this.socket = new Socket("127.0.0.1",TCP_SERVER_PORT);
    That should certainly work on the host the server is running on. Could be your /etc/hosts file. It should map 'localhost' to 127.0.0.1, and your real hostname to your real IP address. This is a common, and rather shocking, problem with some Linux distributions.
    127.0.0.1     localhost
    127.0.1.1     peter-laptop
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    Also can you post the output of netstat -na after you have started the server.
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State     
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN    
    tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN    
    tcp        1      1 192.168.1.70:57052      72.5.124.102:80         LAST_ACK  
    tcp        1      0 192.168.1.70:38987      66.102.9.100:80         CLOSE_WAIT
    tcp        1      1 192.168.1.70:57047      72.5.124.102:80         LAST_ACK  
    tcp        1      1 192.168.1.70:57049      72.5.124.102:80         LAST_ACK  
    tcp        1      1 192.168.1.70:57051      72.5.124.102:80         LAST_ACK  
    tcp        1      1 192.168.1.70:57050      72.5.124.102:80         LAST_ACK  
    tcp        1      1 192.168.1.70:57048      72.5.124.102:80         LAST_ACK  
    tcp6       0      0 :::22                   :::*                    LISTEN    
    udp        0      0 0.0.0.0:41091           0.0.0.0:*                         
    udp        0      0 0.0.0.0:68              0.0.0.0:*                         
    udp        0      0 0.0.0.0:5353            0.0.0.0:*                          I've cut out the bit after "Active UNIX domain sockets" because the message was too long, but I have it if it would help.
    Does this shed any light on the problem?
    Cheers,
    Pete
    Edited by: Puffy on Jan 9, 2009 10:48 AM

  • Problem if mail sent using sockets using j2me devices

    Hi,
    I have a strange problem. I am sending a mail using j2me ( using sockets ). The mail will be sent successfully. But when tried to access using pop service, that mail is never seen in the server.
    I sent a mail from j2me device to gmail account - I can see that mail using the gmail login, but using pop service i am not able to see that mail.
    If I send a mail from browser - I can see the mail in both, the browser and also the pop service.
    Can anyone explain what is the problem ?
    Thanks in advance

    Would you be so kind as to edit your original post and add [SOLVED] to the subject?
    Thanks,
    Craig...

  • Slow download on Mac and Linux using sockets

    We have a need to download as much as possible for a couple seconds using sockets, and we have noticed that Adobes flash player on Mac and Linux are slower then Windows while we get good results on all tree OS using Goggles flash player in Chrome.
    Our setup, client side, is a 1 Gbit/s internet connection throttle by a 100 Mbit/s switch. On the server side, we have an Apache web server (during testing) on a 1 Gbit/s internet connection.
    For testing purposes, we download as much as possible of a 2 Gb big file for approximately 10 seconds. After we connect to the server, via a socket, we send an http request to start downloading the file. Using bytesAvailable, we get the number of bytes downloaded every half second, calculate the average speed for that half second and store that value in an array. After 20 times, we stop downloading and close the socket connection. Finally we calculate the average download speed of the 20 measurements.
    All tests are preformed on version 11.6.602.180 except for Adobe Flash player on Ubuntu were the 11.2 r202 version. Adobe Flash player on Firefox 19.0.2 (other browsers were tested with similar results) and Google Flash player on Chrome 26.0.1410.43. Each OS/player was tested 5 times and presents the average.
    Windows 7 Enterprise (64-bit) 
    Mac OS X 10.6.8 (64 bit) 
    Ubuntu 12.10 (64 bit) 
    Adobe Flash player (NPSWF32_11_6_602_180.dll)
    92.73 Mbit/s 
    14.53 Mbit/s 
    44.25 Mbit/s 
    Google Flash player (pepflashplayer.dll)
    91,89 Mbit/s 
    89.46 Mbit/s 
    91.57 Mbit/s 
    doConnect();
    function doConnect():void {
        socket = new Socket(url,port);
        socket.addEventListener(Event.CONNECT, connectHandler);
    function connectHandler(event:Event):void {
        writeln("GET " + path + " HTTP/1.1");
        writeln("Host: " + url);
        writeln("Connection: close");
        writeln("");
        nStart = new Date().time;
        startTimer();
        socket.flush();
    function writeln(str:String):void {
        str +=  "\n";
        socket.writeUTFBytes(str);
    function startTimer(){
        startTime = new Date().time;
        var myTimer:Timer = new Timer(500,20);// 0.5 seconds 20 times
        myTimer.addEventListener(TimerEvent.TIMER, timeMeasurement);
        myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timeMeasurementComplete);
        myTimer.start();
    function timeMeasurement():void {
        receivedData = socket.bytesAvailable;
        var varJunk:ByteArray = new ByteArray();
        while (socket.bytesAvailable > 4){
            socket.readBytes(varJunk);
        var split:Number = new Date().time - startTime;
        var speed:Number = receivedData * 8 / ((new Date().time - startTime) / 1000);
        startTime = new Date().time;
        downloadList.push(speed);
        receivedData = 0;
    function timeMeasurementComplete():void{
        var len:int = downloadList.length;
        var sum:Number = 0;
        for (var i:int = 0; i < len ; i++) {
            sum +=  downloadList[i];
        downloadResult = sum / len;
        socket.removeEventListener(Event.CONNECT, connectHandler);
        if(socket.connected){
            socket.close();
    In further investigation we built an easy Flash based latency meter. We download a small txt-file, measuring the time between just before we send http-request and until we receive a response from the web server.
    We have the setup as for the speed tests, but we do this 5 * 20 times with each OS/player.
    Windows 7 Enterprise (64-bit) 
    Mac OS X 10.6.8 (64 bit) 
    Ubuntu 12.10 (64 bit) 
    Adobe Flash player 
    4.30 ms 
    66.67 ms 
    10.49 ms 
    Google Flash player 
    4.25 ms 
    4.28 ms 
    4.19 ms 
    doConnect();
    private function doConnect():void{
        socket = new Socket(url,port);
        socket.addEventListener(Event.CONNECT, connectHandler);
        socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
    private function connectHandler(event:Event):void{
        writeln("GET " + path + " HTTP/1.1");
        writeln("Host: " + url);
        socket.flush();
        nStart = new Date().time;
    private function writeln(str:String):void{
        str +=  "\n";
        socket.writeUTFBytes(str);
    private function socketDataHandler(event:ProgressEvent):void{
        var latecy:Number = new Date().time - nStart; // latency in ms
    Using a packet analyzer (Wireshark) on the OS X/Adobe player, the time from http-request is sent to data is received is approximately 2 ms. An ack is sent less then 0.04 ms after the packet is received. Using the socketData event to send a new http-request, just after we measure the time for the last package, can see event created delays. We have a delay between 64 and 67 ms compare that to OS X/Google player with between 1 and 3 ms delay.
    Note: When playing around a timer, that fired a number of times during parts of a large number of latency measurements, we notice that measurements when the timer was running were better. Testing having a empty timer firing as fast as possible constantly during both download and latency measurements we got significantly better results on OS X/Adobe player, although not good. Average download 31,82 Mbit/s and average latency 16,59 ms.

    Bumping this topic again as it's still sort of bugging me, but the problem has been isolated to a few certain sites. On some i get the maximum speed and on others i get snailspeed. One of the slow ones unfortunately is basically anything that has to do with Apple....So all Quicktime movie trailers, iTunes stuff, movies etc are slow, except podcasts that are German. I'm downloading the 30 day trial of iWork and i'm getting whopping 19,2KB/s, when i should be getting about 1300KB/s. You can just imagine the frustration:/
    I'm just wondering am i alone on this or is anybody else excperienceing similar? And as usual, on windows i'm getting full speed all the time, anywhere, grrrr....!
    -CC

  • Direct Connection between clients using sockets

    Hi, I'm a new user and i have a problem with sockets:
    The question is how can i directly connect two users that are already connected to a server in other machine???
    I mean
    user1 is connected to server
    user2 is connected to server
    user1 tries to communicate with user1 but don't want to use the server, and the server only provides the client1's ip
    I first thought to do this:
    user2 asks to server for the info of a client1-server waiting for connections, and i think it could work fine, but only if the ports are not closed by firewall, because client-server will be running in a transparent mode for user and user may not know anything about servers, sockets, ports, etc. the user only will work with a gui or something else and that's all
    Does anybody know what can i do to make this possible???
    PD
    Sorry for my bad English

    It can be implemented like you said. Make one of the clients open a serversocket and pass the ip and port number through the server to the other client with information on where to connect.
    If you're going to use direct connection between clients a lot then I would recommend that every client open a default serversocket at startup and register that information with the server and then every other client can ask the server for the ip and port to whatever client they wish to open a direct connection to.
    Be aware that clients often are behind NATs and firewalls, so if need to deal with those issues you got to use hole punching (http://en.wikipedia.org/wiki/hole_punching) - pref on a known port like 80 - and to deal with the less frequently used application firewalls you can use http encapsulation in addition.

  • Problem using File sharing  in a small office network

    I have a problem using File sharing on an Imac and Macbook Pro.
    My office has a small network running Windows Small office file server 2003. I have one Windows 2000 PC connected to it and 3 Macs, an 2.4 gHz Intel iMac running Leopard 10.5.6 , a MBP running the same and a Mac Mini running 10.5.
    From the Finder Shared window of the Mac Mini, I can see all the computers on the network. It also used to be the case for the iMac, but the MBP could never see the Windows PC’s, not the server or the Win2000. This wasn’t a big problem as I was communicating between the Macs and using the shared printer on the iMac.
    On Monday Jan 19 the iMac was suddenly unavailable to the other 2 Macs. It was working normally on the Friday. The iMac can access the Mac Mini and copy files to it. The Mac Mini can see the iMac but cannot access it. Even trying to connect as, ends in a failed connection. I have tried rebooting, turning File sharing off and then on again to no avail.
    The iMac now also cannot see the Windows PC’s which it previously could.
    To get files from the MBP for printing, I now copy it to the Mac Mini and acces the folder from the iMac, a very tedious procedure. I don’t know why this happened and am scared that the Mac Mini is going to do the same thing.
    All three computers are also running VMware 2.0 with Windows XP pro, and from VMware the server is visible on all the computers.
    Any help will be much appreciated, I live in a small town in South Africa and the local computer suppliers have no knowledge of the Macs.
    I think that the problem with the iMac may have started after a software upgrade to 10.5.6 but I am not entirely sure.
    Thank you
    ajdk

    Well, you're current method sounds pretty good. But if you want to user a file server, hey go ahead.
    What you want to do when you centralize project files is to keep track of which one is the newest and becareful not to overwrite files with the same name. So you either have to set up individual spaces on the server (separate AFP/FTP folders maybe), or you'll need to run a file checkout service.
    The individual space is cheaper, but it's not much of a difference from backing up to the network drive. Since you have Gigabit connections, you might even opt to save ALL the user files on the server instead of just the project files.
    If you want to run a file checkout service, there's two approaches. You can run a service that can host any kind of file, or you can run a version control system for each kind of application (Photoshop, Word, etc.). Please notice, that as you read further and further along, the methods become more and more expensive and complicated. Once you get to this point, it will be necessary to purchase or build software in addition to the Mac OS X Server package.

  • How to make a peer to peer connection in a network using sockets

    My Project is about a multi agent meeting scheduling system.. I've kept the DB in the server and I only use the server to retrieve data from the database. I have used sockets to communicate with the server.
    Each peer in the network is an agent for a perticular user and these agents will be communicating with each other for negotiation purposes..
    The problem I have is that, I couldnt communicate wit other peers using sockets.. I couldnt find any sample java code of sockets to overcum this problem.f sumone has a sample code plz send me.
    And if there is a more efficient and easy way I can connect these peers except sockets, plz tell me and if u have a sample java code plz be kind enough to send.
    This is my final year project in the University
    Thank you
    Sajini De Silva ([email protected])

    Hi Sajinidesilva,
    I think you'll find more support in the [JXTA Community|https://jxta.dev.java.net/] for your project. Also, there's an interesting article to start with : [Introduction to the Peer-to-Peer Sockets Project|http://www.onjava.com/pub/a/onjava/2003/12/03/p2psockets.html].

  • Problem using a conditional suppress in a cross-tab ?

    is there a problem using a conditional suppress in a cross-tab on a row  or summarized field  in crystal XI?
    I am using the following conditional suppress on a summarized field and its rows
             If {@SortCode}=4 then true;
    Sortcode is a group sorting formula field
    the summarized field is a formula field as well.
    All of the summarized fields are suppressed although the cross- tab performs correctly on @Sortcode  and the summarized field when not using the condition        
    it seems to me to be a reporting flow issue although i've included "whileprintingrecords" and "evaluateafter" with no success.
    i have also moved the cross-tab from the report header to group header and applied a conditional suppress on the group header through section expert.
    this supresses the group i dont want but includes grand totals for each group and also varys the number of columns
    i can't filter on sortcode because one of the grand total calculations requires those records and a subreport or second cross-tab does not contain the same number of columns
    the cross-tab is necessary as a client may have columns spanning one to many pages
    thanks for your help

    Hi I have a similar problem,
    I have an clock in solution, where i have some dates with data such as, various entries for a date eg, 01/11/2010 1hr, 01/11/2010 3 hrs etc, 03/11/2010 2hrs , 05/11/2010 4.5hrs, 05/11/2010 4 hrs so i need total for each day and highlight only those days, where total is less than 4.5, including days which donu2019t have records eg 02/11/2010 & 04/11/2010, I summarise in totals using a cross tab, to get summarised output for each day as,
                Totals
    01/11/2010    4
    03/11/2010    2
    05/11/2010    8.5
    in order to get the dates which didnu2019t have records, i added a dataset from Excel spreadsheet where i just have a sequential dates for the year , and use record selection to select only those dates in range which i need to display, so the result i get
    01/11/2010    4
    02/11/2010    0
    03/11/2010    2
    04/11/2010    0
    05/11/2010    8.5
    so far so good, all using cross tab, now i want to suppress rows which have total > 4.5 so the result should be
    01/11/2010    4
    02/11/2010    0
    03/11/2010    2
    04/11/2010    0
    How can i do that?

  • Problem using namespace of XML docs gerenrated by  XMLForm

    Hi community!
    I am facing a problem using namespace within a XSL stylsheet. Let me describe my problem:
    I am using the SAP XMLFormsBuilder within the SAP EnterprisePortal in order to provide a HTML based form for creating and editing specific XML documents. The data in the generated documents is finally presented as HTML using XSL Transformation.
    In the XMLFormsBuilder you define the Schema of the XML document and the HTML GUI of the form. The Schema document looks like below (extract):
    <?xml version="1.0" encoding="utf-8"?>
    <schema targetNamespace="http://www.xmlspy.com/schemas/orgchart"
            xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:xyz="http://www.xmlspy.com/schemas/orgchart" Version="6.3.0">
      <element name="commodity"
               default=""
               minOccurs="1"
               maxOccurs="1"
               ns="p2p"
               xmlns:p2p="http://www.portal.p2p.com">
        <complexType>
          <sequence>
            <element name="administrative_information"
                     default=""
                     minOccurs="1"
                     maxOccurs="1"
                     ns="p2p">
              <complexType>
                <sequence>
                  <element name="creation_date"
                           default=""
                           minOccurs="1"
                           maxOccurs="1"
                           type="date"
                           ns="p2p"/>
    As far as I understand, each element defined in the Schama belongs to the namespace "p2p" and this is exactly what I want.
    The XML document generated by the form looks like below (extract):
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="show_card.xsl"?>
    <commodity xmlns:xf="http://www.sapportals.com/wcm/app/xmlforms"
               xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="/etc/xmlforms/P2PCategoryCard_TEST/P2PCategoryCard_TEST-Schema.xml">
      <administrative_information>
        <creation_date>2005-07-04</creation_date>
    Consequently, the file "show_card.xsl" is the responsible XSLT stylesheet, which looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:p2p="http://www.portal.p2p.com">
      <xsl:output method="html"/>
      <xsl:template match="p2p:commodity">
        <html>
        <body>
          <h2>XSLT Test</h2>
          Creation Date: <xsl:value-of select="p2p:administrative_information/p2p:creation_date"/>
        </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    The problem in the XSLT stylesheet is, that I want to access the XML document elements using their namespace. And this is exactly what does not work for me. On the other hand, if I remove the reference to the namespace:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:p2p="http://www.portal.p2p.com">
      <xsl:output method="html"/>
      <xsl:template match="commodity">
        <html>
        <body>
          <h2>XSLT Test</h2>
          Creation Date: <xsl:value-of select="administrative_information/creation_date"/>
        </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    the stylesheet works fine, but for some technical reasons, which I don't want to explain here, I have to use the namespace when accessing the XML document elements.
    For technical reasons, I cannot change the format of the Schema document and also cannot change the format of the generated XML document. The only file I can change and control is the XSLT stylsheet.
    My question is now, in the case described above, if there is any way to use the namespace in the sytlesheet when accessing the XML elements?
    Any help is appreciated.
    Cheers,
    Adam Kreuschner

    duggal.ashish wrote:
    3. Some XML files contain a "iso-8859-1" character with character code 146 which appears like apostrophes but actually it is : - &#146; and the problem is that words like can&#146;t are shown as can?t by database.http://en.wikipedia.org/wiki/ISO8859-1
    Scroll down in that page and you'll see that the character code 146 -- which would be 92 in hexadecimal -- is in the "unused" area of ISO8859-1. I don't know where you got the idea that it represents some kind of apostrophe-like character but it doesn't.
    Edit: Actually, I do know where you got that idea. You got it from Windows-1252:
    http://en.wikipedia.org/wiki/Windows-1252
    Not the same charset at all.

  • Problem Using Aperture as an External Editor

    I'm having a problem using Aperture as an external editor for iPhoto. I've set preferences to "Edit in Aperture" and selected the Aperture application. When I click edit a photo in iPhoto, Aperture fires up as expected, but it does not load my photo. Nothing seems to be exported from iPhoto into Aperture.
    I can export the same photo to my desktop and then load it into Aperture fine.
    When I set preferences to edit in CS2, this works fine, only Aperture seems to be the problem.
    What am I doing wrong?
    I'm using the following versions:
    - iPhoto 7.0.2
    - Aperture 1.5.4

    If you have Photoshop CS2 then you'd have a better editor using it within iPhoto as follows:
    Using Photoshop (or Photoshop Elements) as Your Editor of Choice in iPhoto.
    1 - select Photoshop as your editor of choice in iPhoto's General Preference Section's under the "Edit photo:" menu.
    2 - double click on the thumbnail in iPhoto to open it in Photoshop. When you're finished editing click on the Save button. If you immediately get the JPEG Options window make your selection (Baseline standard seems to be the most compatible jpeg format) and click on the OK button. Your done.
    3 - however, if you get the navigation window that indicates that PS wants to save it as a PS formatted file. You'll need to either select JPEG from the menu and save (top image) or click on the desktop in the Navigation window (bottom image) and save it to the desktop for importing as a new photo.
    This method will let iPhoto know that the photo has been editied and will update the thumbnail file to reflect the edit..
    If you want to use both iPhoto's editing mode and PS without having to go back and forth to the Preference pane, once you've selected PS as your editor of choice, reset the Preferences back to "Open in main window". That will let you either edit in iPhoto (double click on the thumbnail) or in PS (Control-click on the thumbnail and seledt "Edit in external editor" in the Contextual menu). This way you get the best of both worlds
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Angry Birds Friends on Facebook will not load in Firefox, just white screen. Will load using Chrome, etc?

    Angry Birds Friends on Facebook will not load in Firefox, just white screen. Will load using Chrome, etc? Checked for malware, cleared cache, re-installed Firefox, disabled add ons, enabled java, updated flash and shockwave, etc.

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • N-Queens Problem Using Stacks Help

    I'm trying to solve the N-Queens problem using Stacks. Quite frankly, I'm completely lost.
    Here's the pseudocode from the book:
    "Push information onto the stack indicating the first choice is a queen in row 1, column 1.
    success = false;
    while(!success && !s.isEmpty())
    Check whether the most recent choice (on top of the stack) is in the same row, same column, or same diagonal as any other choices (below the top). If so, we say there is a conflict: otherwise, there is no conflict.
    if (there is a conflict)
    -Pop items off the stack until the stack becomes empty or the top of the stack is a choice that is not in column n. If the stack is now not empty, then increase the column number of the top choice by 1.
    else if (no conflict and the stack size is n)
    -Set success to true because we have found a solution to the n-queens problem.
    else
    -Push information onto the stack indicating tat the next choice is to place a queen at row number s.size()+1 and column number 1.
    And here is my excuse for code so far. I have no idea how to check the diagonals, or how to even really make this work
    {code}import java.util.Stack;
    public class NQueens {
    int row, column, n;
    public NQueens(int n) {
    row = 0;
    column = 0;
    n = n;
    public Stack Solve(){
    boolean success, conflict;
    Stack<NQueens> Qs = new Stack<NQueens>();
    if (Qs.size() == 0)
    Qs.push(new NQueens(1));
    success = false;
    while (!success && !Qs.isEmpty())
    if (Qs.peek().row == row)
    conflict = true;
    if (Qs.peek().column == column)
    conflict = true;
    if (conflict = true)
    Qs.pop();
    Qs.peek().column += 1;
    else
    if (!conflict && Qs.size() == n)
    success = true;
    else
    Qs.push(new NQueens(Qs.size()+1));
    return Qs;
    {code}

    First off I'll address this:
        int row, column, n;
        public NQueens(int n) {
            row = 0;
            column = 0;
            n = n; //here
        }Notice the last line of that. I get what you're trying to do, but think about what the compiler sees there. If you have two variables called 'n', one at the class level, and one at the method level, the compiler must have rules so it knows which one you're talking about. And if it follows those rules, then saying 'n' inside that method must always refer to the same n. Otherwise, how would it decide which one you're talking about? The rule here is that it uses the most local variable available to it, which in this case is your method parameter. So 'n = n' is setting the parameter equal to itself. To refer to the class variable n, use "this.n", like so:
    this.n = n;Now that that's settled, let's address some logic. You'll need to figure out whether two Queens share a diagonal. I can think of at least a couple options for that. First, every time you look at a Queen you could loop through the entire board and make sure that if a piece is in r3c4, that no piece is in r2c3,r4c5,r5c6, etc. Or you could create a new variable for your class similar to your 'row' and 'column' variables that tracks the diagonal a piece is in. But that requires some calculating. And remember, there's 2 directions for diagonals, so you'll need 2 diagonal variables.
    If these are your Row and Column values:
    Row          Column
    00000000     01234567
    11111111     01234567
    22222222     01234567
    33333333     01234567
    44444444     01234567
    55555555     01234567
    66666666     01234567
    77777777     01234567And these are your diagonal values:
    Diag 1                    Diag 2
    0  1  2  3  4  5  6  7          7  6  5  4  3  2  1  0
    1  2  3  4  5  6  7  8          8  7  6  5  4  3  2  1
    2  3  4  5  6  7  8  9          9  8  7  6  5  4  3  2
    3  4  5  6  7  8  9  10          10 9  8  7  6  5  4  3
    4  5  6  7  8  9  10 11          11 10 9  8  7  6  5  4
    5  6  7  8  9  10 11 12          12 11 10 9  8  7  6  5
    6  7  8  9  10 11 12 13          13 12 11 10 9  8  7  6
    7  8  9  10 11 12 13 14          14 13 12 11 10 9  8  7Then examine the relationship between Row(R), Column(C), and Diagonals 1 and 2 (D1/D2):
    RC   D1,D2
    00 = 0,7
    01 = 1,6
    02 = 2,5
    03 = 3,4
    04 = 4,3
    05 = 5,2
    06 = 6,1
    07 = 7,0
    10 = 1,8
    11 = 2,7
    12 = 3,6
    13 = 4,5
    14 = 5,4
    15 = 6,3
    16 = 7,2
    17 = 8,1You'll notice that D1 is always the same as R + C. And D2 is always the same as C subtracted from 7 plus R, giving:
    int d1 = row + column;
    int d2 = (7 + row) - column;But remember, that 7 in the formula above, is based on how big your grid is. So whatever your 'N' is, whether its a 10x10 square or a 574x574 square, that 7 should be changed to (N-1)
    So those could be your variables to track diagonals. What I'm noticing in your current code, is that you never change your row and column variables...so every Queen is always at r0c0. You should probably put values for those in your parameters for the constructor, in addition to n. Then the diagonals can be calculated from those.
    Edited by: newark on Apr 17, 2008 10:46 AM

  • Send html page (with images) using sockets

    I am trying to implement http and am coding this using sockets. So it is a simple client-server set up where the browser queries my server for a webpage and it should be shown. The html itself is fine, but I can't get any of the images to show up! All of my messages give me a status "200 OK" for the images, so I cant understand what my problem is!
    Also, is the status and header lines supposed to be shown in the browser? I didnt think so but it keeps showing up when I query a webpage.
    Please help!
    import java.io.* ;
    import java.net.* ;
    import java.util.* ;
    public final class WebServer
         public static void main(String argv[]) throws Exception
              // Set the port number.
              int port = 8888;
              // Establish the listen socket.
              ServerSocket ssocket = new ServerSocket(port);
              // Establish client socket
              Socket csocket = null;
              // Process HTTP service requests in an infinite loop.
              while (true)
                   // Listen for a TCP connection request.
                   // (note: this blocks until connection is made)
                   csocket = ssocket.accept();     
                   // Construct an object to process the HTTP request message.
                   HttpRequest request = new HttpRequest(csocket);
                   // Create a new thread to process the request.
                   Thread thread = new Thread(request);
                   // Start the thread.
                   thread.start();
    final class HttpRequest implements Runnable
         final static String CRLF = "\r\n";
         Socket socket;
         // Constructor
         public HttpRequest(Socket socket) throws Exception
              this.socket = socket;
         // Implement the run() method of the Runnable interface.
         public void run()
              try
                   processRequest();
              catch (Exception e)
                   System.out.println(e);
         private static void sendBytes(FileInputStream fis, OutputStream os)
         throws Exception
            // Construct a 1K buffer to hold bytes on their way to the socket.
            byte[] buffer = new byte[1024];
            int bytes = 0;
           // Copy requested file into the socket's output stream.
           while((bytes = fis.read(buffer)) != -1 ) {
              os.write(buffer, 0, bytes);
              os.flush();
         private static String contentType(String fileName)
              fileName = fileName.toLowerCase();
              if(fileName.endsWith(".htm") || fileName.endsWith(".html")) {
                   return "text/html";
              if(fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") ) {
                   return "image/jpeg";
              if(fileName.endsWith(".gif")) {
                   return "image/gif";
              return "application/octet-stream";
         private void processRequest() throws Exception
              // Get a reference to the socket's input and output streams.
              InputStream is = socket.getInputStream();
              DataOutputStream os = new DataOutputStream(socket.getOutputStream());
              // Set up input stream filters.
              InputStreamReader ir = new InputStreamReader(is);
              BufferedReader br = new BufferedReader(ir);
              // Get the request line of the HTTP request message.
              String requestLine = br.readLine();
              // Display the request line.
              System.out.println();
              System.out.println(requestLine);
              // Get and display the header lines.
              String headerLine = null;
              while ((headerLine = br.readLine()).length() != 0)
                   System.out.println(headerLine);
              // Extract the filename from the request line.
              StringTokenizer tokens = new StringTokenizer(requestLine);
              tokens.nextToken();  // skip over the method, which should be "GET"
              String fileName = tokens.nextToken();
              // Prepend a "." so that file request is within the current directory.
              fileName = "C:\\CSM\\Networking\\Project1" + fileName;
              // Open the requested file.
              FileInputStream fis = null;
              boolean fileExists = true;
              try {
                   fis = new FileInputStream(fileName);
              } catch (FileNotFoundException e) {
              fileExists = false;
              // Construct the response message.
              String statusLine = null;
              String contentTypeLine = null;
              String entityBody = null;
              if (fileExists) {
              statusLine = "200 OK" + CRLF;
              contentTypeLine = "Content-type: " +
                   contentType( fileName ) + CRLF
                   + "Content-length: " + fis.available() + CRLF;
              else {
              statusLine = "404 Not Found" + CRLF;
              contentTypeLine = "Content-type: text/html" + CRLF;
              entityBody = "<HTML>" +
                   "<HEAD><TITLE>Not Found</TITLE></HEAD>" +
                   "<BODY>Not Found</BODY></HTML>";
              // Send the status line.
              os.writeBytes(statusLine);
              System.out.println(statusLine);
              // Send the content type line.
              os.writeBytes(contentTypeLine);
              System.out.println(contentTypeLine);
              // Send a blank line to indicate the end of the header lines.
              os.writeBytes(CRLF);
              // Send the entity body.
              if (fileExists)     
                   sendBytes(fis, os);
                   fis.close();
              // file does not exist
                     else
                   os.writeBytes(entityBody);
              // Close streams and socket.
              os.flush();
              os.close();
              br.close();
              socket.close();
    }

    ok. i figured it out. STUPID mistake. i forgot to include "HTTP/1.1" in my status line!!!

  • Downloading a binary file using sockets without length known

    Hi all,
    I'm trying to download a binary(.exe) file using socket, where the length of the file is not known. Please take a look at the code I'm using:
          var readBin = socketBin.read();
         <-- Here comes the code that checks for http Content-length header field
         ; If content-length field is available, then I'll use it to download file, else proceed with following code -->
        pBar.reset("Downloading plugin..",null);pBar.hit(readBin.length);       
                while (1)
                    binFil.write(readBin);     //'binFil' is the file, into which downloaded file is written.
                    readBin = socketBin.read();
                    pBar.hit(readBin.length);
                    if( socketBin.eof || readBin.length<=0){
                        break;}          
                binFil.write(readBin);
                binFil.close();
                socketBin.close();
    Problem is: I'm able to download file within 10 seconds when content-length is known. But when content-length is not known, its taking about 1 and half minute to download, also the progress bar gets struck for much of time.
    FYI: socket is opened in binary mode, file is getting downloaded correctly(even though it takes abt a minute). BTW Im using CS5.5 extendscript
    I'm not able to figure out where the bug is.

    Hi, Srikanth:
    Sevaral points.
    #1 When posting code, please use the web interface and the >> icon and choose Syntax Highlighting >> Java. Otherwise your code is just too hard to read and gets misformatted.
    #2 Apropos of #1, your script as written does not work, because this line:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$ 1/$2/$3/$4");
    has an extra space in the $1 and should be this:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$1/$2/$3/$4");
    Please take an extra moment to make sure that when you asking for help, you do so in a way that makes sense. Otherwise it takes too much effort to help you, and that is frustrating.
    #3 If we instrument your script by adding a line to the while() loop:
                while (1)
                    binFil.write(readBin);
                    readBin = socketBin.read();
                    $.writeln(Date()+" Read "+readBin.length+" chars, eof is "+socketBin.eof);
                    if(  readBin.length<=0){         break;}              
    We get output like this:
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 631 chars, eof is false
    Mon Jul 11 2011 12:07:06 GMT-0400 Read 0 chars, eof is false
    Result: undefined
    Therefore, we can reasonably conclude that the last read at the end of the data stream returns a short read when the other side blocks.
    Unfortunately, that's clearly insufficient since you can get short reads all the time.
    I'm not sure why you say the length of the file is not known, HTTP provides it to you in the Content-Length field of the response.
    But the easy answer is to get the server to close it for you. This is easy, enough, with Connection: close. Why were you specifying
    Connection: keep-alive, anyhow?:
                var requestBin =
                "GET /" + parsedURLBin.path + " HTTP/1.1\n" +
                "Host: " + parsedURLBin.address + "\n" +
                "User-Agent: InDesign ExtendScript\n" +
                "Accept: */*\n" +
                //"Connection: keep-alive\n\n";
                "Connection: close\n"+
                "\n";
    This yields a nice tidy:
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 735 chars, eof is true
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 0 chars, eof is true
    I suspect you're also better off using something like socketBin.read(64*1024) for a 64k buffer size, but it doesn't seem to effect the on-the-wire protocol, so perhaps its not so important.
    If you don't want to reply on the server

Maybe you are looking for

  • What happened to ACR

    When running the latest version of Lightroom (I reinstalled it today) and I use the "edit in Photoshop" command on a DNG file they are opening directly in Photoshop, bypassing ACR.  Yesterday they went to ACR first.  I've reinstalled Lightroom and Ph

  • How to create an additive dissolve

    How do I create an additive dissolve in After Effects ? I found this link, but I'm not convinced of the result or I may be doing it wrong...!? http://forums.creativecow.net/archivepost/2/450224 Thank you.

  • Can't charging

    can't charging properly, the socket at the bottom of tochpad is too loose,anybody can tell me how to fix? many thanks

  • HT1807 my friend give me a whatsapp app as a gift in australia but i cant install on my iphone 4s please tell me a solution

    My friend send me a app as a gift but i can't install on my iphone 4s please tell me the solution. App Name  WHATSAPP Sender Destination    Australia(Sydney) The Problem is i open the app and he says reedem the code i reedem the code but he tell THIS

  • IE6 problem

    Hi everyone, I followed every step from this thtread to mimic the oracle apex bar, but I still have a problem. Creating a DHTML Drop down When I run my application in internet explorer 7, everything is fine. When I run it in internet explorer 6, the