Need help on TCP communiction architecture. Patterns, books?

Hi
I am currently developing a Java ME application that uses TCP for communication. Unfortunately the binary protocol I have to implement on the client is half-duplex whereas TCP is full-duplex. So I had to artificially limit and synchronize transmission and reception by using sync blocks, locks on mutex objects and message qureue decoupling. While implementing the protocol, step by step new cases appeared where I had to tweak the existing locking a bit. Now, the protocol seems to work (no stress/system test yes) but to be, the architecture is not as good as it could be and probably a bit fragile. For the next release/refactoring I'm looking for a better way to solve the problem.
There are different possible message flows:
- Client transmits, Server sends ACK
- Clients is Idle, Server requests data, Clients sends ACK, Client sends response, server sends ACK
- Exceptions must be handled: Reception timeout, bad packet format etc. Then the packets must be resent...
Right now, I have a main thread that will use a queue to store messages. When transmission starts, it will send messages. If it fails, it will roll back the queue and send again. Then it waits on a queue for the ACK using a timeout. There is a second thread that is used for reception. It waits on a blocking inputstream read, parses the messages and puts them into a reception queue.
In this current architecture, there are some problems: When receiving data, sometimes I have to already handle and interpret the packets right now without storing it into a queue because because I need to send an ACK immediately which again depends on the outcome of the handler. But this could mess up a ongoing transmission/reception so I have to sych it by using a flow control mutex object of which I don't think it's a good way. A second problem is, that when I'm sending the response messages to a server request, the reception thread is locked because the response sending is already called by the reception thread itself and I'm deep down in the call stack. My work-around is to start a new thread to transmit the packets and wait for an ack so the reception thread can go on receiving the ack.
But I don't have a good feeling about this.
Is there anyone with a good approach or any hints on books or patterns about this? I bet there must be other people before me having the same problems... :)
Thanks a lot!
/Jan

stelzbock wrote:
Hi, thank you all for the valuable comments. I try to get to a bookstore to get a deeper look into that book because it's unix and I don't have anything to do with any NIX OSes. But probably I could use some of the general archticture ideas.
jschell wrote:
You have a protocol and messages.
The protocol layer handles the send/receive the message layer handles what messages to send and expected responses.
Hmm, interesting, is the message layer higher than the protocol layer? I mean, what tasks do the message layer cover?
Yes. Specifics depend on details of the actual specification.
The message layer might use three methods provided by the protocol layer.
- Send request and receive response
- Send request
- Receive response.
The message layer constructs the message while the protocol layer handles the CRC (as an example.)
I need to send an ACK immediately which again depends on the outcome of the handler.I would like to think that you are mis-interpreting that.
Normally something like that would be something like the following
- Get the message
- Verify the CRC
- Send the ACK if the CRC is valid.
In a case like that it is still part othe protocol rather than the message flow.generally, I would agree. But what I am doing is an extremely resource optimized embedded protocol that runs via TCP but could also be RS232 or CAN or anything else. It's packet header contains only 3bytes and the protocol supports dedicated messages that are used for instance to set a configuration item on a remote device. In this case, the message content must be parsed and interpreted before sending an ACK because in this case, the ACK acknowledges not only the header but the payload as well.Still depends on the specifics.
But then the ACK is a response and nothing more. At the message level you can sequence it as
- Hold protocol (method provided by protocol that dedicates socket to this flow)
- Send request and receive response
- process request
- Send Ack response (protocol layer can actually encapsulate ACK or message layer can do it.)
- Release protocol (releases the socket.)

Similar Messages

  • Hi! I need help, today I connected my mac Book Air to a tv for a presentation and as soon as I conected it the image on my screen went bigger. And I cant find the way to put it back as it was before. The Images are too big! heelp

    Hi! I need help, today I connected my mac Book Air to a tv for a presentation and as soon as I conected it the image on my screen went bigger. And I cant find the way to put it back as it was before. The Images are too big! heelp

    Morning DeeHutton,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at this article:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/ts2802
    Best of luck,
    Mario

  • Need help in TCP/IP expert

    as the attachment , the blinkblink.vi is the main function i want to do .
    how do i connect using the TCP/IP ?using the testserver.vi and the testclient.vi
    need help. any expert here?
    Attachments:
    blink blink.vi ‏10 KB
    testserver.vi ‏11 KB
    testclient.vi ‏11 KB

    LOL! wrote:
    as the attachment , the blinkblink.vi is the main function i want to do .
    define "do"!
    Do you want to send the new LED state whenever the two booleans change? What is the server supposed to do with the data?
    (Your blinker code makes little sense, for example [i] is always less than 3 so at least one operation is meaningless. Also, the VI consumes all CPU resources when the switch is off. It is often easier if you make a clean diagram layout, not with wires going in all directions or often nowhere. Have you done any tutorials or classes?)
    LabVIEW Champion . Do more with less code and in less time .

  • Need help in TCP/IP

    Hi, im really new to labview.
    need some help in TCP/IP.
    im kind of stuck on it.
    i try the example in labview.
    but only able to communicate if it send and receive on the same computer.
    when i use 2 computer using lan connection (ethernet wire)
    it cant send or receive when i enter the address and port(which i found from tool>option>VI Server.)
    (correct me if i key in the wrong port or address)
    im trying to use the labview example to understand how it work and program it on my program.
    but i cant seem to make it work with using 2 computer connecting using lan connection (ethernet)
    this attachment is my program which has help given for me to complete.
    Attachments:
    LOCATORMOD2.vi ‏21 KB

    im just a student, doing a project.
    let me explain what my program about.
    Computer A is to write and Computer B is to read.
    when computer A have input and write to computer B, it read and send back the value which it has in the server to Computer A.
    i need to use tcp/ip because there only 1 read computer that read the input and send back the value.
    and more computer on writing.
    to understand more about my program the attachment i have attach is the program and the text file to store all the values.
    thanks.
    Attachments:
    TESTCAR1.txt ‏1 KB
    LOCATORMOD2.vi ‏21 KB

  • Need help for downloading java at mac book retina

    i want to download java at my mac book pro retina but everytime we downloaded its not working..i need this because im going to use it to open my bank account...everytime i gonna check my bank account i need to use another computer not this my mac.why?? can you help me please.

    Banks do NOT use Java-in-a-Browser for anything, at all. If you have received a suggestion to conduct banking with JAVA enabled in your Browser, someone is attempting to commit a crime, with you as the intended victim.  You are being scammed and should report it to the Police.

  • Need help migrating photos (and hopefully album books) from iphoto6 to iPhoto '11

    hello all and thanks in advance for your help !
    Just purchased a new 21.5' iMac on Friday, and have been successfully moving data etc from my existing (5-year old) iMac running OS X (10.6.8) to my new iMac using an ethernet connection.
    I now need to move our 12,000 photos from the old iMac, and it currently has iPhoto 6 (ver 6.0.6 (322)) on it. My wife created three large "album books" which we have not been able to order because we have iPhoto 6, and the books are no longer supported on iPhoto6. I didn't upgrade that computer to iPhone 9x which I believe does allow books because I knew we were going to get the new iMac.
    So my question : is it possible to migrate the photos as well as the existing folders, albums, and especially the BOOKS to our new iMac ??  My wife REALLY doesn't want to recreate three years' worth of books !
    Thanks in advance for your replies - Jeff

    For the record - Connect the two Macs together (network, firewire target mode, etc) and drag the iPhoto library intact as a single entity from the old Mac to the pictures folder of the new Mac - launch iPhoto on the new mac and it will open the library and convert it as needed and you will be ready move forward.
    Book have changed a lot since iPhoto 6 and may not convert well though
    LN

  • Need help recovering corrupted outlook express address book

    So my dad's address book won't open. First, outlook express says that the address book isn't installed properly, and then that the address book file is corrupted. It has important business contacts, so its imperative that I save the data.
    How can I get into the file? I can open it in notepad and I see a lot of the text, but its mostly names and I can't find any email addresses. Any help would be greatly appreciated.

    Certainly you can.
    Use Desktop Manager > Sync. 
    Setup Outlook Express to sync with your device in Desktop Manager > Sync > Confgure. Find and select Outlook Express as the sync partner to your BlackBerry handheld address book.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • HELP!!!!! I need help putting windows on my Mac Book Pro using parallels!!

    hi, I have a mac book pro and im tryin to install windows on it as there a some programs that i want to on my mac for my phone, and games. Anyway every time i go to install it, it comes with up with an error message saying that a removable device was removed check then start again. the error message is 0xc00000e9! ive looked on the net and it all for pcs not macs!!
    Can anyone help?
    Thanks

    Please post Parallels related questions on the Parallels forums as Apple discussions only provide support for Apple products:
    http://forums.parallels.com

  • Need help Printing Address labels from Address Book

    I have a new iMac using OS X.4 1. I want to print address labels for Christmas cards. 2. I want to print several address labels of the same information for return address labels. I can't seem to figure it out. I've read the Help. I don't see where to put the # of labels per page. I created a Directory with only one name it it (so it would print several times on one page.) I selected Avery Standard - label 5162. Under label I selected Distribution List. I seem to be missing something.
    Thanks for any help you can give me.

    I wanted to do the same thing. The only way I was able to do this was to create a new group, then enter my name and address 30 times (the number of labels per sheet on Avery 8160). Then I was able to print as many sheets as I wanted. The bad news is you have to enter 30 times, the good news is once you done it you can print as many labels as you need. good luck

  • Need help with TCP/IP example?

    Hi,
    I'm still new to labView 7.1. I'm trying to understand the TCP/IP
    On TCP/IP Server/Client example, does the server generate the data and than send that to the client? After client receives the data, it processes the data and it displays the data on the client side? If yes, than how would just display the data on client side by 1st process it on server side? Or can you do that way?
    Thanks,

    As any other "server" on the internet (web server, mail server), the server passively waits for connection requests on a certain port. The client initiates a connection to the server to get the data.
    It is up to the server program to decide what to serve, so you you can process the data any way you like before it is sent out.
    The only important issue: You must ensure that server and client agree on the type of data being exchanged, the rest is up to you.
    LabVIEW Champion . Do more with less code and in less time .

  • Need help on preparation for Certification test Booking code- C_JA320_04

    Hi,
    I am planning to take certification on
    "<b>SAP Consultant Certification
    Development Consultant SAP NetWeaver 2004 – Web  Application Development Focus Java</b>"
    I would like to know how to get material to clear this test.
    Please provide me all the all information you have for this test.
    Please advise on tips to clear this certification in case anybody already clears this test.
    Regards,
    Vasanth

    Try to find it thru OKP (Online knowledge Products),  Ofcoures this is paid but less when compared to direct class. Also, help.sap.com is the only best source for you to get material for certification.
    Thanks,
    Raags

  • Need Help with J2EE Connector Architecture!! Please!

    Scenario:
    We are trying to establish connectivity to a CTG using the new JCA connector specifications.
    We have our input in the form of a string but the Interaction.execute(ioRecord, ioRecord object specifies record object as parameters.
    How do we create a record that correctly represents our current input string?
    Is there a predetermined record format that we must use for out connection or can we create our own record?
    If we can create our own record how is it converted and padded properly for a byte stream that is required by the CTG?

    Send a message to [email protected] they help answer tough questions for a fee.

  • Need help connecting 23" ACD to Mac book pro

    I have a 17" MBP and a 23" ACD the ACD works beautifully with my G5 tower. Now when I try to connect it to my MBP nothing happens. The display power indicator is on but the screen is black. When I tell the MBP to detect displays nothing happens. What am I missing?

    I have the same issue. A little more interesting on mine, which you can try with another monitor, find an analog monitor and using the DVI to Analog adapter that came with your computer, connect it to the analog monitor. Mine works with an analog monitor connection through the adapter but not to a straight dvi connection.

  • How can this pattern work? need help!!

    the model i need have 3layers:JSP+EJB+SocketServer, i know EJB can act as Socket Client(not Server),but the
    main problem is that i must use a .dll or .lib file(written in
    c) in EJB to packge the socket data.someone says EJB
    can use JNI while EJB Spec won't allow it, i dont't want
    to take the risk also.Is there any other way can work?
    (use runtime in EJB?)
    if EJB can't work in this pattern,can i have another choice? (JSP and SocketServer can't be replaced)
    NEED HELP!

    Use the Mediator pattern.

  • HT1600 I am not able to connect my mac book pro to the airplay mirroring...I need help please

    I have set up everything as supposed to.  I have the Apple TV connected to the same wireless as my Mac Book Pro.  My computer is only a couple months old so it is compatable.  I just bought the Apple TV, and when I go to the display on the menu bar, it does not show the apple tv device detected. I dont know what to do.  I need help

    is airplay enabled on Apple TV? is the device up to date? Is your computer up to date?
    Also see
    http://support.apple.com/kb/TS4215?viewlocale=en_US&locale=en_US

Maybe you are looking for

  • Apple's multicam workaround is bogus?

    On Pogue's blog, Apple supposedly gave this as a workaround for multicam editing: Apple intends to restore this feature in an update, calling it "a top priority." Until it does, here's a stopgap facsimile of multicam editing: If you drag two clips in

  • Obiee 11.1.1.6  Actions- Invoke a Java Method screen is empty

    Hi All, I have created and deployed an EJB for obiee11g by using the example provided in the below link http://www.rittmanmead.com/2010/09/oracle-bi-ee-11g-action-framework-java-ejbs-and-pdf-watermarks/ I have mapped oracle.bi.actions also But I am n

  • PSE 7 Crashes During Photo Mail Steps

    After installing PSE7, and repeatedly attempting to create a photomail with different photos, PSE7 crashes at the step where you go from selecting the images and writing your message to the step where you select the type of photomail template to use.

  • Assign standard text (SO10) in transport request

    Hi Experts, How can i assign the standard text i've created in SO10 to a transport request. Thanks! Best Regards, Kurtt

  • SMS Out of order fix

    Not sure if this has been figured out, and posted already - but I found a fix for the out-of-order SMS message issue. It seems to only happen when you exit the SMS app while it's sending. In other words - let the SMS send, then go back to your messag