My last (hopefully) socket question...

Hi,
thanks to the people who helped me get my sockets up and running. I got pointed in the right direction (when I was convinced something else was the problem) and now I fixed my bug. So, now when I receive things over the socket, I always receive the same thing. On the sender side I am printing out what I am sending. The receiver prints out what it receives. The receiver is always printing out the first thing it received, even though the sender has claimed to send something newer. This goes on and on. The sender always prints out that it is sending something new, yet what the receiver prints out is what it read the first time.
Is there some flushing of the object input stream that I need to do? I tried setting ois.enableResolveObject(true) but my compiler tells me that method has protected access, so I must not be able to call it.
For reference, here is my receiver code:
ArrayList remoteEvents = null;
while (running) {
        remoteEvents = null;
        remoteEvents = (ArrayList)ois.readObject();
        while (remoteEvents == null) {
          remoteEvents = (ArrayList)ois.readObject();
        for(int index=0; index < remoteEvents.size(); index++) {
          System.out.println("receiving event " + ((SimEvent)remoteEvents.get(index)));
        addRemoteEvents(remoteEvents);
}Any ideas?
Thanks.

Ok, here is some more of the code. I tried clearing the ArrayList each time before calling readObject() and now I am thoroughly confused again. If I clear the ArrayList then nothing is received over the socket, i.e. the ArrayList received has size() == 0. If I don't clear the ArrayList then I continually receive the same thing that was sent the first time. Here's the code:
ArrayList remoteEvents = new ArrayList();
while (running) {
        remoteEvents.clear();  //causes empty ArrayList to be received
        remoteEvents = null;
        remoteEvents = (ArrayList)ois.readObject();
        while (remoteEvents == null) {
          remoteEvents = (ArrayList)ois.readObject();
        for(int index=0; index < remoteEvents.size(); index++) {
          System.out.println("receiving event " + (SimEvent)remoteEvents.get(index));
        addRemoteEvents(remoteEvents);
}Just for reference, here is the sender code:
for(int index=0; index < msg_queue.size(); index++) {
        System.out.println("sending event " + (SimEvent)msg_queue.get(index));
      //now send msg_queue over the socket
      ConnectionObject co = (ConnectionObject)peerSockets.get(machine);
      try {
        co.oos.writeObject(msg_queue);
        co.oos.flush();
      } catch (Exception e) {
        System.err.println("error writing messages to machine " + machine);
        System.err.println(e.getMessage());
        e.printStackTrace();
        System.exit(-1);
}Any hints on why the clear() on the ArrayList would cause such a difference in behavior would be appreciated.
Thanks.

Similar Messages

  • HT201441 i just bough a used iphone but looks that it was found and i cant unlock it. its still link to the last user my question is how do i find out who is the last owner so i can unlock it

    i just bough a used iphone but looks that it was found and i cant unlock it. its still link to the last user my question is how do i find out who is the last owner so i can unlock it

    peeweenborre wrote:
    i just bough a used iphone .... its still link to the last user ...
    If you cannot get this information from the seller
    Removing a device from a previous owner’s account
    You need to return the Device for a refund,

  • Hopefully easy question...

    I am new to TestStand and have a couple of (hopefully) easy questions.  I am using TestStand 3.5.
    1)  I have written a couple of sub-sequences in another file that we use for common tasks.  Some of the parameters we pass will always be the same variable name.  Is there a way I can get that default parameter name to show up when I write the program to call this sub-sequence so I wont have to enter it each time?
    2)  When I run a program that calls a sub-sequence in the above file, the first time I run it, I get an error saying the resource already exists...  If I open the sub-sequence file in TestStand, and then close it, it is fine after that.
    Thanks for your help!

    With TestStand the answer is usually 'yes' it is just a matter of which way is best for you.
    1)
    TestStand has a full application interface so that you can pragmatically read parameter names and types, and populate calling programs with the right stuff.  This takes some learning.  There may be an easier way depending on what you are doing.
    I'm not sure what you mean when you say you write a program to call the subsequence.   In  TestStand 4.0 ( don't have 3.5 installed) you can create a Sequence Call template step that can be used in new sequences that you program.  That is, I can open a new sequence, drop a generic Sequence Call step and rename it, configure it to call your subsequence by choosing the right path, sequence file, values/expressions to be passed to the subsequence, and then I can save this step as a template (drag to the Step section of the template window).  Then, when I have a brand new sequence, I can drop an instance of this template step into my sequence, with the parameter values preconfigured.  Assuming all the expressions are valid, you're ready to go. 
    2)
    Without more information I can't help with this one.  Perhaps the sequence file that contains the called subsequence is not in one of your search directories (see Configure>>Search Directories) and therefore it can't be found until you open, identify and save the calling sequence file. What error code are you getting?

  • Flex 3 Beta 2 Socket question

    Hi,
    Last night I spent about 3 hours looking for problem which
    came up for me yesterday. Before I'll get back to writing sample
    app which tell me if there is a problem in my code I will ask if
    anyone has noticed this behaviour.
    I'm connecting to c# socket with Socket class. First message
    goes nicely. But when I'm trying to write next messages nothing
    happends. Messages from socket are coming all the time. The problem
    is only with writing.
    I'm using writeUTFBytes method to write. RIght after writing
    I'm executing flush() n socket.
    Is it possible it is the problem with Flex Socket in 3 Beta
    2?

    in
    http://bugs.adobe.com/jira/browse/FB-9947
    it is remarked that re-establishing an internet connection resolves
    the issue, but it DOES NOT!
    I still get the
    'Flex Builder cannot access the server containing the Start
    Page content.
    If you are offline, try connecting to the network and
    refreshing the Start Page.' message.
    Andy

  • What is better???--sockets question

    I have a server that receives one client (one thread of them) per socket.
    Is it better to have all in the same socket?
    where is the bottle�s neck? in the processor or in the bandwith?

    ok
    and what is better for my server:
    1) receive each client in a different socket
    2)receive all clients in one socketAFAIK you would need a new port for each server socket. How then can your clients know which port to connect too? Therefore I think (2) is the proper solution.
    For a general implementation of a tcp server, have a look at my solution at http://www.ebi.ac.uk/~kirsch/monq-doc/monq/net/TcpServer.html . You can download the code by following the link at the bottom of that page. Comments/questions welcome.
    Harald.

  • Java Socket Question

    Bonjour all,
    I have a bit of a weird question about Socket output and input streams, when I use the following code everything works fine.
    Socket soc = new Socket("123.456.789.1", 1234);
    +//     Send data request+
    +DataOutputStream dos = new DataOutputStream(soc.getOutputStream());
    dos.writeInt(INT);
    dos.flush();
    +//     Wait for reply+
    ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
    ArrayList<String> files = (ArrayList<String>) ois.readObject();
    How ever if I declare my Output and Input Stream readers together, my program justs hangs.
    Socket soc = new Socket("123.456.789.1", 1234);
    +//     Define streams+
    DataOutputStream dos = new DataOutputStream(soc.getOutputStream());
    ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
    +//     Send data request+
    dos.writeInt(INT);
    dos.flush();
    +//     Wait for reply+
    ArrayList<String> files = (ArrayList<String>) ois.readObject();
    Anyone got any ideas why this is??
    Edited by: 836869 on 15-Feb-2011 04:02

    You have to flush your ObjectOputStream first, it is worth noting that you are not, 1) using an ObjectOutputStream, 2) flushing it before opening the ObjectInputStream.
    Try this.
    ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream());
    oos.flush();
    ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());If you want to swap an integer as part of the header, you can do the following.
    ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream());
    oos.writeObject(INT);
    oos.flush();
    ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
    Integer intValue = (integer) ois.readObject();

  • Z97S Krait Edition CPU Socket Question

    Hi, I'm wondering whether the socket backplate on the reverse side of the the board is insulated. So far I have been unable to find any specific information online - although it seems that some ASUS products come with this as a protective feature. I'm just wondering whether this comes as a default for all socket 1150 boards. The reason I'm asking is because I am concerned that this item may come into contact with the chassis of my case and would like some peace of mind on this matter.
    I've attached a photo of the item in question - the silver socket behind the X shaped backplate (btw this is not a actual photo of my motherboard).
    Cheers

    the image isn't show up, you have to add tag in your post to show it
    ie:
     edit your post, then choose "Attachments and other options"
    then select desire placement/location in your reply and click on
    [Insert Attachment 1 in the message]
    [Insert Attachment 2 in the message]
    or use direct tags in your message to access the attached files with:
    Code: [Select]
    [_attachthumb=1]
    [_attachthumb=2]
    without "_" in front

  • Hub/Socket question

    Just ordered an upgrade from old BT broadband to Infinity 2 and a question occurs to me. Sales person arranged for an enginer to come out to (I think) do something to the socket. Does the Infinity Hub have to be pluged into a specific socket or will anyone do?
    I ask at the hub is plugged into a socket in the study which is a faff to get to so if the engineer needs to get to it I'll have to do some furniture moving before they get here.
    Any assistance appreciated.

    Hi Randor and welcome
    Please have a read if this - http://bt.custhelp.com/app/answers/detail/a_id/13736/c/346 as this answers everything you've asked.
    -+-No longer a forum member-+-

  • Client Server Socket question!

    Hello all,
    how are ye.
    I would like to ask a question.
    I would be graterful for any suggestions relating to my query.
    i am creating a program that needs to communicate over a network
    it has two parts
    P1) sends request to the other program mainly about account information and
    also updates.
    P2) the second part among other things listens for messages on a port from Program One.
    but also must be able to interface with the user who is using Program Two, the user should be able
    to view account info update delete search etc.
    my problem is how will i get the second program todo both operations do i need
    to create another thread that listens and if i do this. will i be able to
    like add info to a database from this thread.
    Mainly i need suggestion as to how i should implement a scenario like the above.
    I am sorry if i havent spelled out my problem in a clear manner.
    Very grateful for any assistance.
    Thank you all :-)

    http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
    That should help you out.

  • Dynamic select --hopefully simple question

    I have read alot of threads on doing a dynamic select. I am have no knowledge of AJAX so this is tough for me. I have looked at Denes and Carl's examples. I have one question and I hope its a simple one. I have two select lists. The second field is dependent on the input from the first box. I know we put a query that should bringin the on demand process but is this query the result for the second box or do I need to put the same query in the LOV box for the second field?
    For example, the first select list contains module names, based on the module name the user picks, the names in the module should populate the second select list. In the lov for the first select list, I have a query for the modules. In the on demand process, I have a query that takes uses the module name to look for the users, and in the the second select list, I have the query that does the same thing as the query in the on demand process. What do I put in the lov for the second select list.

    Nevermind, I downloaded firefox and was able to see what variable wasn't working...

  • Quick (hopefully​) RAM question

    We have a A105-S2071 and a A105-S4334.  I would like to upgrade the RAM in both.  My question: can I just put the two 1 GB RAM cards from the S4334 into the S2071? 
    Thanks
    ja

    Satellite A105-S2071
    Satellite A105-S4334
    Yes, the same modules are sold for both.
    -Jerry

  • Hopefully simple question. Event ID 2 Task Category (2) Lenovo Message Center Plus Admin

    Hey group,
    Wanted to ask you guys what I was missing. In my event log as the title implies I have a Event ID 2 Task Category (2) error in Lenovo Message Center Plus Admin coming as a result of a 404 error. Issue is I don't know what page it is looking for when it is tossing me the 404 error. Is this a result of Lenvo Updater goofing up using the ADM templates for GPO or is this something else? Would be helpful if it registred the non working link it was trying to obtain so we could isolate it better. Thoughts on this? Thanks!

    try this when you download the file save it to your download folder then right click it and run as admin. it says there is no Lenovo Digital Signature I tried to install it didn't work but I did it this way and it worked
    Thinkpad R61 7733-1GU
    Thinkpad X61T 7762-54U
    Thinkpad X60T 6363-4GU
    Did a member help you today? Thank them with a Kudo!
    If a post answers your question, please mark it as an "Accepted Solution"!
    Regards,
    GMAC

  • Unix Domain Socket - Question about work around

    Since Unix Domain Sockets are platform dependent and Java is platform independent, it does not support it.
    However, I am sure some of you have worked with them and found some good work around.
    Elsewhere Jtux was suggested as a possible fix. However, I have not seen any good testimonials to it working. Also, if there are any security issues with this software. The website is here: http://www.basepath.com/aup/jtux/
    Does anyone have any other suggest?
    Thanks.

    I am modifying a current app. I must use the Unix
    Domain Sockets. I have no choice in the matters. It's
    for security reasons that they must be left in place.I can only guess that you do not understand my suggestion.
    The proxy does a domain socket to regular socket - just a pass through. You write this in C/C++.
    In your java app, as one option, you use Runtime.exec() to start the proxy. Then you use a java socket to connect to it. You can pass options to the proxy to control the socket behavior on both ends.
    In terms of usage there are a number of variations on the above.

  • Java Sockets Question

    Hi Guys,
    I've got a problem. I'm using raw socket connections for Web and other queries. I know I can use URLConnect and similar but they do not provide the flexiblity that I need so please do not suggest that I use those isntead.
    My problem is that I can set the read timeout (socket.setSoTimeout) and I can set the write timeout (socket.setLingerTimeout) but I there does not appear to be a setting to set the connection timeout.
    I'm using this for proxy servers, and the proxy servers tend to die quite often and when I try to connect to a server that no longer works the connection request just sits there forever, never actually times out. Now, the timeouts work fine on the read/write but not on the connection.
    I know I can create another thread that's a timer and force close the socket thread but that doesn't seem like the proper way to do it.
    Thanks,

    Great. Thanks, Played with that overloaded constructor and finally got it to work under linux. The funny thing is it wouldn't work under windows when I was testing because windows uses its own timeout.

  • Simple Socket Question / Error...

    I'm testing out a socket connection for an RDP app on the playbook.
    Flash Builder Burrito 4.5
    Adobe AIR SDK 2.5 Hero
    Playbook SDK 0.9.2
    Playbook Sim 0.9.2
    VMPlayer running in Bridged Networking mode
    public function RDPApp()
                   var socket:Socket = new Socket();
                   socket.addEventListener(Event.CONNECT, onConnect);
                   socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
                   socket.addEventListener(Event.CLOSE, onClose);
                   socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
                   socket.addEventListener(ProgressEvent.SOCKET_DATA, onReceivedData);
                   socket.connect("http://www.google.com", 80);
                   socket.close();
                   stage.nativeWindow.visible = true;
              private function closeWindow(event:MouseEvent):void{
                   stage.nativeWindow.close();
              protected function onConnect(event:Event):void
                   // TODO Auto-generated method stub
              protected function onIOError(event:IOErrorEvent):void
                   trace(event);
              protected function onClose(event:Event):void
                   // TODO Auto-generated method stub
              protected function onSecurityError(event:SecurityErrorEvent):void
                   // TODO Auto-generated method stub
              protected function onReceivedData(event:ProgressEvent):void
                   // TODO Auto-generated method stub
    The code above throws on the sim and on the desktop:
    IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2031: Socket Error. URL:http://www.google.com" errorID=2031]
    Googling this error message indicates that the client flash app has not received the required policy file from the server.
    I was under the impression that AIR apps running on the desktop sandbox (Playbook included) do not require the retrieval of the policy file.
    Any help is much appreciated.
    Matt

    For sockets you need to first load the securitypolicy file then call methods on it.
    ref : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
    Message was edited by: saisri2k2

Maybe you are looking for

  • Download problem / This copy of itunes is corrupted or not installed correctly. please reinstall itunes (-42404)

    have windows 7 ... itunes worked on my computer before  ... but when I tried to download new version of itune  ...  I get this message ;  This copy of itunes is corrupted or not installed correctly. please reinstall itunes (-42404)  ...  this has bee

  • Previous period posintg

    Greetings!!! I have maintained authorization group F_BKPF_BUP to restrict posting in previous period.. It works fine for all tcodes except CO11 Any solution plz Regards

  • Applications constantly quitting unexpectedly and not responding

    Lately, my computer has been having quite a bunch of issues. One of the major ones is applications constantly crashing and quitting unexpectedly. For example, when I want to go edit a video with iMovie, I have to literally reopen it 5 times just so t

  • LR4/Bridge CS5/InDesign CS4

    I understand why LR 4 will not allow Drag & Drop from Lightroom to InDesign. Prior to purchasing LR, I was quite happy using the ability to drag and drop photos from Bridge, right into my InDesign document. Since I do not have that luxury any longer,

  • Absoulte Position Help

    Hello im creating an email campain and they keep mentioning to make sure the right colum is not absolute position and needs to be in a table... here is a link of what it looks like www.proofsnow.com thats what it should look like... but im using abso