Aynchronous and Synchronous communication TCP socket

Hi All,
I have written a client/server test application to test the performance of the java socket library. I tested the application in two scenarios,
1) Asynchronous communication between client and server, client sends data(packet size is 500bytes) without waiting for the server response. I tried to upload 1mb file. The time took was 1.5mb/sec which is reasonable.
2) Synchronous communication between client and server, client sends data (again, packet size is 500bytes) and waits for the server response (all server responds is OK (1 byte data)). The amazing thing in this test was the performance went down drastically!!! it came down to 5-10kb/sec, which is unbelievably nonsense or I am doing something nonsense.
code snippet (server side)
//reading from the socket (tried both buffered and non-buffered )
inputstream = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
//writing to the outputstream of the socket (server side)
outstream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream))
//then flush the data, in case
client side code is very simple,
while(not EOF)
outputstream.write(buffer); //buffer size is 500bytes, as I mentioned above
if(synchronous)
wait for server response, otherwise don't
I don't know why in case of synchronous communication it should bring down the speed so much, may be I am using wrong java classes or java sucks!
I would greatly appreciate any help on this.
Platform used: JDK 1.3.1, WIN2K.

I have to break it up because that's how it's done in the real application. The test application that I have written is just part of the product that I am working on.
To give you the background, we have C++ product where we are porting server side of the whole product to java.
The client(which is written in c++) sends data(which is basically attributes), of size 500bytes in every request. The no. of request depends on how big the model(3D Model) is. In case of very huge models (will have MBs of attributes) the client takes long time to send all the attributes, which is the case with java server (client still in c++). But the in case c++ server it doesn't make any difference, the data transfer rate is same no matter how big the model is.
I know if I increase the size of the packet I will get higher performance, but unfortunately I can't do that. That's how the client is designed to do it.
thanks,
Ganesh

Similar Messages

  • Synchronous and asynchronous communication tcp/ip

    Hello all:
    it is common to make synchronous communication between client and server by socket tcp/ip. But I'm needing now to establish an asynchronous communication. I mean:
    0.- The server is a multithread process that has the property to establish one connection for each client that wants to send him messages.
    1.-The client process sends message permanently to server.
    2.- The server processes the request, but don't have to respond to the client.
    3.-Only when the user want it, he sends messages to client by web application reusing the same communications that are opened between client and server process.
    I hope to explain my problem.
    Regards.

    Hello all:
    it is common to make synchronous communication
    between client and server by socket tcp/ip.A socket tcp/ip can be synchronous or asynchronous or both.
    But I'm needing now to establish an asynchronous
    communication. I mean:Is this purely asynchronous or can it be either.
    0.- The server is a multithread process that has the
    property to establish one connection for each client
    that wants to send him messages. Fine, any mode would be okay.
    1.-The client process sends message permanently to server. By permanently do you mean;
    - it is deleted from the client,
    - it is store on the server is a write once read many media. i.e. it is permenetly on the server and cannot be deleted/altered.
    2.- The server processes the request, but don't have to respond to the client.The server should never have to respond to the client. e.g. the server can go down so the client nees to live with the possibility it won't get a reply.
    Synchronous or Asychronous describes how the reply is send. No reply means it is neither.
    3.-Only when the user want it, he sends messages to client by web application reusing the same communications that are opened between client and server process.Are you using socket or a web application server ie. HTTP.
    You wan to be able to reuse the connection. You can do this in any of the case mentioned so far.
    >
    I hope to explain my problem.I hope you will explain your problem too.

  • Synchron communication via Socket

    Hi everyone,
    Is there a way to make TCP Sockets communicate in a synchron manner?
    I mean, I send a message over a socket and be blocked until I receive
    the answer.
    (PS: I don't want to use any other API (like RMI, or JMS or etc etc).
    I ask, whether the Socket implementation in java.net package can do
    this implicitly.)
    Thank you very much

    No no, this is not a ServerSocket anyway. Assume there is just
    one Socket that is already connected.
    I send a message, i.e. I call for example
    outputstream.println("....");
    where 'outputstream' is the Stream that I obtained using my socket.
    Normally my code continues to run after that line. If I expect
    an answer, I receive it via an "response from the other side- event".
    But for example consider RMI. If I call a method of a remote object,
    Object o = remoteobj.aMethod();
    then my thread is blocked until I receive a response from the
    remoteobj. I do not have to listen to an additional event, everything
    is done synchronously.
    I want to do the same thing as RMI with my socket (outputstream).
    I want my code to be blocked until I receive an answer from the
    other side.
    That was my question.
    Best Regards
    I mean, I send a message over a socket and beblocked
    until I receive
    the answer.Do you mean by being blocked you do not have a socket
    listening anymore to make additional connections?

  • Communication with database using TCP sockets connection

    Hi all,
    I am bit of a newbie when it comes to databases. In a project I realised over te passed few weeks, I communicated with an 11g database using an application I created with VS Express. It uses an ODBC connection. I now want to connect a PLC to the same database. These PLC's don't have the ability to install an ODBC client so I need something different.
    I am easily able to open a TCP socket on the PLC and send data from there. I would like to know if I can start a TCP sockets connection with our 11g server and send all queries directly. The other (already suggested) option would be to have the PLC connect to a PC that reads this information and hands it over to the ODBC connector, but that would mean I need an extra PC just to 'translate'.
    I have been searching these forums for socket, TCP and more and feel it is possible, but I need a good document as a reference to show/tell me how it's done.
    Thanks in advance,
    Marijn

    The TCP/IP interface to Oracle is undocumented (and hugely complex anyway). You'll need to use a higher layer iterface or setup your own infrastructure.
    We need more information about what is available to you inside the PLC.
    Can you use Java? If so, perhaps use thin JDBC?
    Can you sent HTTP requests? If so you could set up your own Web services to handle this.
    If you can only use C or C++, Oracle has interfaces there too.. it's called OCI (Oracle Call Interface) and thats as close to the networking layer as you can get.
    Finally if you can use .NET Oracle has a Fully Managed Oracle Data Provider for .NET that you could use.
    But if all you can do is super low level network access and none of the above then you will need to set up an intermediary as you mentioned.

  • TCP Socket connection in CLOSE_WAIT status and not getting closed

    I am facing an issue with the TCP socket connections not getting closed and they are in CLOSE_WAIT status for ever.
    As a part of batch process in our application, emails are sent with 4 embedded images. These images are downloaded from 3rd party site with IP say "UUU.XXX.YYY.ZZZ"
    The images are embedded to email as follows
    1. An URL object is created with the site url.
    URL urlPhoto = new
    URL("http://UUU.XXX.YYY.ZZZ/email/photos.jpg");
    2.     The image cid is created with the URL object and the image name
    HtmlEmail htmlEmail = new HtmlEmail();
    String cid1 = htmlEmail.embed(urlPhoto,
    "photo.jpg");
    3.     The image cid is added to the email template by replacing the ${cid1} and the email is sent.
    <td valign="top">
                   <img src="cid:${cid1}" width="279" height="274">
              </td>
    When a mail is sent, 4 new TCP connections are opened and are put in CLOSE_WAIT status for ever. For every mail sent 4 new connections are opened. In UNIX there is an upper limit on the number of open file handles (defaults to 1024) at any point of time. The open TCP connection has the underlying socket in CLOSE_WAIT status and is not getting closed at all. When the upper limit (1024) is reached the batch process is throwing the following exception and terminates.
    Caused by: com.inet.tds.ap: java.net.SocketExceptionjava.net.SocketException: Too many open files
    at com.inet.tds.am.a(Unknown Source)
    at com.inet.tds.TdsDriver.a(Unknown Source)
    at com.inet.tds.TdsDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at com.hcomemea.batchprocess.dataaccess.database.BaseJdbcDao.openConnection(BaseJdbcDao.java:106)
    ... 12 more
    When I run the command lsof in UNIX which list the open file handles in the system
    $ /usr/sbin/lsof -p 22933 -i | grep CLOSE_WAIT
    java 22933 build_master 297u IPv6 129841943 TCP integration.com:47929->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 298u IPv6 129841947 TCP integration.com:47933->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 299u IPv6 129841950 TCP integration.com:47936->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    java 22933 build_master 300u IPv6 129841970 TCP integration.com:47952->UUU.XXX.YYY.ZZZ:http (CLOSE_WAIT)
    ���list of 935 connections similarly�
    I tried 2 solutions
    1. Got the HttpURLConnection from the URL object and invoked disconnect method on the same. But it doesn�t work.
    2. Ran the batch process java program with the parameter �Dhttp.keepAlive=false to close the underlying connection but didn�t help.
    I need the underlying sockets to be closed and not put in CLOSE_WAIT status after sending the mail.
    Is it the problem with the embed method of HtmlEmail object not closing the underlying socket connection.
    If anyone has faced this issue before, kindly let me know the possible solutions for the same ASAP.
    Thank you,
    Ramesh G

    This sounds more like a problem due to connection pooling at middle tier/application server.
    If that has been ruled out, then you might to enable DCD or set expiry time on the server.

  • Regaring Synchronous communication and ASynchronous Commu

    Hi,
    Can any please describe me  for the above Synchronous communication and ASynchronous Commu. Please don't send any weblogs.. Or Documentations please  type the answers in simple language  just to understand excatly.
    1.  when to use these.
    2.  where to use..
    3.  How its Usefull

    Hi,
    When you make a synchronous call i.e the message is sent, the receiving system is  active and can accept the call and further process it if necessary.
    It is advantageous in a scenario which requires immediate return of data to the sender system.
    One example would be where, you create a purchase order with account assignment in the sender system, and you want to perform a budget check in central accounting before you save the purchase order.
    A disadvantage would be that both systems are required to be active.
    In Asynchronous communication the receiving system does not necessarily have to be available at the time a function call is dispatched from the sender system. The receiving system can receive and process the call at a later time. If the receiving system is not available, the function call remains in the outbound queue of the sending system, from where the call is repeated at regular intervals until it can be processed by the receiving system.
    An example would be, you are sending a purchase order to a vendor system. The sending system cannot influence the availability of the receiving system. If the receiving system is not available, the purchase order can be sent repeatedly until the vendor system is available again.
    The obvious advantage of async communication is that the receiving system does not have to be available at the time the function call is made and the disadvantage is that processes that require an immediate response to the sender system cannot be executed using this method.
    Hope this gives a clear idea of sync n async communication.
    Regards,
    Chandra

  • HttpConnection & TCP Sockets

    I wish to receive an httprequest on a tcpsocket. That is one midlet opens an httpconnection and the other midlet opens a tcp socket. Is it posiible for two way communication between them.
    If so how can the tcp socket read the data.

    Hi Briggsd!
    I'm playing with some sockets.
    can you please help me?!
    J2ME uses only HTTP connections?
    and what are the sockets? what is the difference between CLDC socket and J2SE Socket?
    is there any other way to communicate with a Servlet?
    and very important..
    is there a difference if it's using GPRS or 3G?
    would the http connection work for all? and just the connection speed would change?
    help me!!

  • RFC destination for synchronous communication (message type SYNCH)

    Hi experts,
    I am trying to configuare ALE settings.waht i did is
    My sending & receiving systems are one server with different clients.By using SALE transaction
    1.crated logical systems.(LS_800 &LR_810)
    2.Assigned those to clients.
    3.Created RFC destination
    4. Created modelview assign sending & receiving
    systems and message type.saved it.
    4.generated Partner profile.Here i am getting below problem
    Target system LR_810
    RFC destination for synchronous communication (message
    type SYNCH)
    Partner profile LR_810 SYNCH does not exist
    Generate partner profile or
    specify outbound partner profiles for message type
    SYNCH
    Target system LS_800
    RFC destination for synchronous communication (message
    type SYNCH)
    Partner profile LS_810 SYNCH does not exist
    Generate partner profile or
    specify outbound partner profiles for message type
    SYNCH
    Regards;
    Upender.

    Hi Shital;
    Thanks for your replay;
    Still am getting the Same Error;
    Thanks;
    Upender.

  • Help SOAP to RFC Scenario using BPM (Synchronous communication)

    Hi,
    I am doing a scenario from SOAP to RFC scenario(Synchronous communication).  Here I am creating a PM Notification in the SAP system through a webservice. 
    I am using three BAPI'S here,
    1. BAPI_ALM_NOTIF_CREATE 
    2. BAPI_ALM_NOTIF_SAVE
    3. BAPI_TRANSACTION_COMMIT
    I am successful in calling the first BAPI from the Web Service.  For this I have not used BPM.  But to commit the transaction(PM notification in this case), I have to execute the other two BAPI's as well.  I have to pass the output of first BAPI to the second BAPI and then execute the 2nd BAPI.  And finally have to execute the 3rd BAPI.     FYI, 3rd BAPI is not dependent on any output.  It has to be executed independently after execution of the first two BAPI's.
    How can I execute this scenario?  Do I have  to use BPM?  If yes please let me know the steps in detail.  I have not done any BPM scenario till now.  So please answer me in detail.
    Thanks in Advance,
    Vijay
    p.s. reward points are must

    Hi Vijay,
    Yes, You will indeed need a BPM in this case...
    Based on my understanding of the Scenario u have explained, here are the steps that would be needed.
    1. Receive With the Sync-Async Bridge open.
    2. Transformation Step (Between the source Request and The BAPI_ALM_NOTIF_CREATE Request)
    3. Send Synchronous
    4. Fork
    5. In one Branch of the fork - Transformation (Between the BAPI_ALM_NOTIF_CREATE Response and API_ALM_NOTIF_SAVE Request)
    6. In the other branch of the fork - Transformation (Between a Dummy Source and the BAPI_TRANSACTION_COMMIT Request)
    7. Send Synchronous (to make the 2nd BAPI Call)
    6. Transformation ( BAPI_ALM_NOTIF_SAVE Response and the source Response)
    7. Send Asynchronous (to make the 3rd BAPI call)
    8. Send the Source Response and close the Sync-Async Bridge.
    There might be alternative ways also of doing it...
    Also a better design would be to take care of the 2nd and the 3rd BAPI call within the code of the 1st RFC Function Module.
    Regards,
    Abhy Thomas

  • Sender JMS Synchronous communication channel not picking up files from JMS

    Hello,
    One of our Sender JMS synchronous communication channel (used Sync/Async bridge in the module section to make it Synchronous) is not picking up files from JMS system though the channel looks to be active (greeen).
    When I am trying to stop the channel, it is giving error as "1 of 1 administered and selected channels have not been stopped", and after this when I start the cannel again it shows green but not picking up any files.
    if anyone is haivng any solution for this, please reply back.
    Thanks in advance.

    Messages available in JMS system? please check queue's if message were there and it is not picking up then some thing wrong with cc.
    simple solution create new communication channel with same details and try to use the same.

  • IDOC to SOAP Synchronous Communication

    Hi Experts,
    Scenario is IDOC to SOAP.
    And Expecting Response(Sucess/Failure) from Third Party system.
    My understading is IDOC wont support Synchronous communication.
    If synchronous comm is possible in IDOC to SOAP scenario could you please elobrate the Requirements and detail the procedures with ID and IR configuration.
    If not How this can achived in this scenario.
    Regards,
    Seshu.

    [IDoc to SOAP Synchronous with BPM|http://wiki.sdn.sap.com/wiki/display/XI/IDoctoSOAPSynchronouswith+BPM]
    Regards
    Raj

  • Synchronous communication scenario

    Hi
       I have a current scenario involving a SRM system sending purchase orders to an external supplier through XI 2.0 ( XI-A ). The supplier systems responds synchronously to the PO that it receives with an acknowledgement code. This acknowledgement code is interpreted back in the SRM system and suitable action is taken. End-to-End synchronous communication.
    Now, we have an initiative of uprgrading the SRM systems and the XI systems. ( XI moving to 3.0 SP13 ( XI-B) ). Since we are doing this upgrade in phases, we will have phases of the project wherein the same external supplier system will receive Pos from both the SRM systems ( old and new )- i.e the supplier will receive POs from both XI-A and XI-B. The question now is :
    1) Since the communication is synchronous, the supplier system need not know where/which system the PO is coming from - it just needs to reponse to the incoming PO request and send the response - back to where the request came from - my assumption is that - the communication pipeline is opened with the request coming in - so the supplier system need not mention any URL to where their response should go to. The response would automatically use the same communication pipeline opened up the request and go back to the XI box where the request came from Is my assumption right ?
    2) If not, any suggestions on how we could route the response back from the supplier to the appropriate XI box ??
    Thanks in advance for your valuable suggestions regarding this.

    Hi Vijay,
       If at all you have uploded wsdl file for the webservice you no need to create data types for the same even for the same as RFC also.
         Create message mapping and drag the wsdl file which you have imported as External Definiations and there you will be having request and response parameters..Do the mapping accordingly(according to your requirement).
    Mapping like:
        Wsdl(Request)---->RFC (Input parametrs)
        RFC (out parameters)------>wsdl(Response)
    Create message interface with Synchronous for outbound
        No need of DT,MT if at all if you import the wsdl file.
       Hope i am clear.
      Please let me know if you have any queries..!
      Thanks and Regards,
      Chandu.
    null
    null

  • Synchronous Communication from 3rd party XI server

    Hi,
    I have the following XI landscape where the receiver system is on 1 XI server, and the sender system is on the other XI server, where between the 2 XI servers, the communication protocol used is HTTP.
    For synchronous communication between sender (SOAP client) and receiver system (SAP ABAP proxy), do I still have to prototype BPM in the sender's XI server to relay the SAP result via HTTP?
    Any advise will be greatly appreciated. 
    vivian

    Hi Vivian
    I don't know what you mean by "prototype BPM", but I don't think you need a BPM in this scenario.
    If I understand you correctly, the flow is as follows:
    1. Sender SOAP client makes synchronous call to first XI server.
    2. First XI server routes call to second XI server (probably using XI protocol) - still using synchronous messaging.
    3. Second XI server routes call to receiving system (synchronous ABAP proxy).
    4. Synchronous response propagates back the opposite way.
    In this case, there is no need for a BPM.
    Regards,
    Thorsten

  • Synchronous communication of JDBC adapter with BPM

    Hello XI-Experts,
    Could you please give me example where BPM is having a Synchronous communication with JDBC adapter??
    plz do help.
    Thanks & Regards,
    Vanita

    Vanita,
    Let's consider the below scenario.
    A File contains the SQL query, you need to fetch the data from DB system using that SQL query and write it to a file. You can configure like below
    File Adapter to pick the file and send it to BPM
    Mapping Transformation to create the SQL request
    Call DB using JDBC adapter Synchronously
    Mapping Transformation to Convert the Response from DB and write it to a file.
    Does it seems to be a valid scenario you are looking for? Any questions let us know.
    If you are looking for any blogs then check below:
    Synchronous JDBC: /people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step
    File-RFC-File: /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit
    ~Raj.

  • Synchronous Communication between two Decoupled Orchestration

    Hi All,
    Is there a way I can achieve synchronous communication between 2 orchestrations (decoupled orchestrations) where I need to pass multiple parameters from calling orchestration to called orchestration.
    Thanks,
    Sumit
    Sumit Verma - MCTS BizTalk 2006/2010 - Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

    Hi Sumit,
    if you have hundreds of orchestration means lot of small small business processes which are tightly coupled...
    It is better to publish process / orchestration as service so it will  SOA base ..it will work isolate. but remember if you publish more web base service. it will be burden on IIS. we have only one Host instance to handle..we can't create more host
    instance to handle like in-process host in one server..we have to go for cluster environment..so first approach will be window base service (if possible achieve business process ) to handle by in-process host instance.
    If you have many small small services then we need one master service to watch/process all the services.
    Exmaple...
    Like one process A, need to execute five small services/processes a1,b1,a2,c1,c3
    and Process B need to execute four small services/processes b1,b2,a1,c1
    You have to go for canonical schema and master entry table where you can dynamically change or attached or remove small service.  
    Regards
    Suman

Maybe you are looking for