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?

Similar Messages

  • 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

  • Only one receiver in local communication via socket

    I am simulating a network of 4 nodes that exchange messages between each other on localhost.
    Each node has two threads: Sender thread and Receiver thread that use DatagramSocket for communications:
    For the Sender socket:
    DatagramSocket sock_sender = new DatagramSocket(null);
              sock_sender.setReuseAddress(true);
    DatagramPacket dp = new DatagramPacket(buffer, buffer.length,
                             InetAddress.getByName("localhost"), PortA);
    Now for the receiver socket,
    DatagramSocket sock_recev = new DatagramSocket(null);
              sock_recev.setReuseAddress(true);
              sock_recev.bind( new InetSocketAddress (InetAddress.getByName("localhost"),PortA)
    To conclude, I have multiple receivers that listen to the same remote port.
    The issue now is that only one node can receive data from other sender processes!
    Is there any idea about the reason of this issue and how to process to avoid it?

    If they all use the same address and port all the receivers should see the same packets, including their own.
    Have you considered using a multicast address?

  • 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

  • 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.

  • I need to send a message via socket from a C program to a Java program

    Hi,
    I need to send a message via socket from a C program to a Java program. The message has three data: a long, an integer and a string.
    How can I put those three fields in a array of bytes in C? How can I extract those same three fields from an array of bytes in java?
    Thanks a lot!

    A few options:
    JNI
    Corba
    Using sockets directly
    take your pick.

  • 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 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

  • IDOC-- JDBC server with synchronous communication.

    Hi  SAP PI Experts,
    we have requirement as per the below. could you suggest the best possible way to execute this below.
    we need to send the outbound IDOC to JDBC and reponse file from JDBC should be posted to ECC in IDOC format.
    as per my knowledge synchronous communication is not prefered for IDOC scenaioro.
    please advise the best possible solution in PI 7.1
    Regards,
    Krushi.

    IDoc not supports Sync communication but JDBC Receiver channel supports it.
    if you have any limitation like not to use ccBPM then 2 options
    1)Change IDoc to ABAP Client Proxy ,Proxy supports sync communication.
    2)IDoc-->PI(JDBC Lookup)--->IDoc(recv).
    if the response message from JDBC is not huge then try option 2.
    Regards,
    Raj

  • Whats the difference between sending messages via socket and MQs?

    Whats the difference between sending messages via socket and MQs?

    Soph wrote:
    Whats the difference between sending messages via socket and MQs?With JMS (and the like) your application uses a socket to connect to a central server called a "*Message Broker*". Over this connection it can send or receive messages.
    A Message Broker is somewhat analogous to a database server. Multiple clients connect to it to exchange messages. As with a database a client first establishes a connection, then requests specific facilities like subscriptions.
    It creates a strong decoupling between sender and receiver and handles stuff like allowing multiple receivers for the same message, queuing of messages for applications not currently running and so on.
    (And don't worry, you can get perfectly good message brokers for free such as openMQ and activeMQ.)

  • 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

Maybe you are looking for

  • IMessage on MacBook Pro - how to use mobile number?

    So I upgraded to 10.8.2 on ML and IOS 6 on other devices. I notice on the iPhone that my iMessages can be received by default only to the mobile number. I previously turned iMessage off because frankly it was a complete PITA and more trouble than it

  • PO error in Process-Order Unit PU not convertible into unit lot of req

    Hi ALL, SRM 5.0 SP13 ECS Service based req with order unit LOT was pushed to SRM . SC got approved in SRM with order unit LOT, PO got approved with order unit LOT and now the PO is in error in process state. I looked up RZ20 to find the message "Orde

  • Capture License for Deemed Export

    Hi all, While creating export license J1ILIC01 I am getting an error: Enter valid Sold to party/Ship to party. I am not able to create a license. Kindly suggest Thanks & Regards Kishan

  • Where can i find the Media browser folder

    Hi guys hey where can I find the media browser folder if I want to delete some FCPX videos to free up some space.

  • My software can not create with thinapp for use in workspace

    i have problem appear  this error when i am create a software with thinapp for workspace for all of them i get this error when click on save Could not copy file C:\Users\Administrator\NTUSER.DAT -> C:\Program Files (x86)\VMware\VMware ThinApp\Capture