Delaying send data until event occurs

Hii all,
I'm new to java socket programing.
i'm trying to develop simple system using TCP socket for client server communication over a network. I use AWT for user interfaces.
The client program is supposed to get two inputs from user via 2 Text fields and send those to server.
In my client program i have a method to listen server socket send data to server and inner class for user interface thing and i have called those 2 in main method consecutively.
I want to delay calling listenSocket() method until the user click submit button. i think i have to use some synchronized methods but i dont have much idea of how to do it.
I have attached the code here.
Can anybody help me plzzzz? any suggestions would be appreciated.
public class Client {
/*for TCP socket connection*/
Socket clientSocket=null;               
PrintWriter out = null;          
BufferedReader in = null;
private String accountNo =null;
private String accountType =null;
public static void main(String[] srgs) {
Client client =new Client();
CustomerRequestUI requestUI =client.new CustomerRequestUI();
client.listenSockect();
public void listenSockect() {
try {
clientSocket = new Socket("localhost", 1234);
out =new PrintWriter(clientSocket.getOutputStream(),true);
out.println(accountNo);
out.println(accountType);
} catch (UnknownHostException e) {
     // TODO Auto-generated catch block
     System.out.println("Unknown host: localhost");
     e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
     System.out.println("No I/O");
     e.printStackTrace();
class CustomerRequestUI extends Frame implements ActionListener{
          //declare components
          Label accNumLabel     =null;
          Label accTypeLabel     =null;
          TextField accNumText =null;
          TextField accTypeText=null;
          Button submitButton     =null;
          Button closeButton =null;
     public CustomerRequestUI(){
          this.setTitle("Customer Request");
          this.setLayout(new GridLayout(3,2));
          this.setBackground(Color.lightGray);
          accNumLabel =new Label("Account Number");
          accNumText =new TextField(10);
          accTypeLabel =new Label("Account Type");
          accTypeText =new TextField(25);
          submitButton =new Button("Submit");
          closeButton =new Button("Close");
          //add components to frame
          this.add(accNumLabel);
          this.add(accNumText);
          this.add(accTypeLabel);
          this.add(accTypeText);
          this.add(submitButton);
          this.add(closeButton);
          //add ActionListener to components
          accNumText.addActionListener(this);
          accTypeText.addActionListener(this);
          submitButton.addActionListener(this);
          closeButton.addActionListener(this);
          this.pack();
          this.show();      
     public void actionPerformed(ActionEvent event) {
     Object source =event.getSource();
     if(source ==submitButton){
          accountNo =accNumText.getText();
          accountType =accTypeText.getText();
     if(source ==closeButton){
     this.setVisible(false);                    this.dispose();
     System.exit(0);                    
}

If you want to listenSocket after a user clicks submit, why don't to call listenSocket when the use clicks submit.

Similar Messages

  • Send data from event to SUD Dialog

    Hi,
    I have a script that trigger an event function ( OnCursorChanged)  
    and i want that each time the event is triggered ,send a string to my Dialog (contains list box of string ).
    how could i do that?  
    thanks

    Hi,
    maybe this will work, you must start your dialog non-modal and can use the CustomAction-Event in the dialog:
    Sub OnCursorChanged-SUB
    Dim myDlg
    Dim sDialogCode : sDialogCode = "theNameOfYourDialogCodeProperty"
      If Nothing is SudNonModalDlgLst(sDialogCode ) Then
        Set myDlg = SUDDlgCreate(sDialogCode , sITMPath & "test2.SUD")
        Call myDlg.Show()
      Else
        Set myDlg = SudNonModalDlgLst(sDialogCode )
      End If
      Call myDlg.RunCustomAction
    End Sub

  • Power Shell script to send a email with event details when an specified event occur

    I want a power shell scrip to send a email to a specific email id with the event details when an specified event triggered. The default option to trigger the email on event occur is failed.

    Why is everybody now saying "I want, I want, I want"
    Can you say what is happening?  Can you post a script with a line that is failing?  No!  All you want is a free script.
    Start by learning how to script.   Try at least to write a simple "hello World" script.  Until then you cannot post here.
    ¯\_(ツ)_/¯

  • Dynamically set send date to defer event subscription

    Hi,
    I need to have an event subscription when new employees are hired, but defer payroll notification until their respective future hire dates.
    I am entertaining the thought of having one event subscription defined for the event, but deferring subscription processing using future send date by dynamically setting the send_date attribute to the future hire date of each new employee. Are there any PL/SQL API available to dynamically adjust the send date for new hires?
    Thanks in advance.

    Thank you for your feedback. I don't see this feature request in the idea list yet. You should post it here so other can vote on it.
    Randy

  • Need solution for the following sync error: "iTunes could not sync calendars to the iPad "iPad name" because an error occurred while sending data from the iPad"

    Need solution for the following sync error: "iTunes could not sync calendars to the iPad "iPad name" because an error occurred while sending data from the iPad"

    I want to add that I deleted all the old back-ups and created a new back-up without any issues except sync problem.

  • "...an error occurred while sending data from the iPhone" - caused by latest iPhone update today?

    I've been syncing my iPhone to my (non-apple) desktop for several months without difficulty.
    Today I accepted the latest upgrade to my iPhone software.
    Since it installed, it will not sync.
    It gives the error message "iTunes could not sync calendars to the iPhone "Steve's iPhone" because an error occurred while sending data from the iPhone."  After rebooting the desktop, the error repeats, and it's now in hour 2 of the continuing message "Syncing Steve's iPhone (Step 2 of 2) - Finishing sync"
    Has anyone else run into this Undocumented Feature of the latest upgrade?
    As bugs go, this is pretty serious for those of us who depend on syncing the iPhone and desktop for our business!
    Thanks to anyone who can help!
    Steve Callender

    Tried rebooting the phone, and now it works.
    Guess there's 2 lessons here -
    Boot again when installing new SW, even if the phone reboots itself during installation, and
    Boot to see if that fixes a problem before posting it.
    Steve

  • Catch client disconnect without sending data?

    I am writing a Java Servlet and I need to know if the client has disconnected (pushed the stop button, closed the browser, etc) without sending data. Basically, I need to call socket.isOutputShutdown() on the connected socket. However, the Java Servlet interface does not provide access to the socket, only the socket's output stream. In the book Java Servlet Programming (2nd edition) by Jason Hunter, page 159 suggests attempting to write a single space and then catching the resulting error. This works fine for HTML, but my servlet is not guaranteed to be sending HTML. It could be sending a file, in which case miscellaneous "ping" spaces would corrupt it.
    Is there a way to check if the client has disconnected without sending "ping" data from a servlet?
    Thanks,
    Nathan Lewis
    P.S. I thought I posted this a couple days ago, but I can't find it now.

    This appears to be very close, but I don't think it'll work. I want to know if/when the client hits the stop button on their browser (or otherwise closes the TCP socket). The Unbound event only occurs if:
    1. The session times out
    2. The user reloads the page. (Then Unbound is immediately followed by a Bound event)
    However, an Unbound event doesn't seem to be occuring if the user hits stop. It doesn't occur until the session times out. If I set the session timeout interval to something short, the Unbound even is occuring even though the client is still connected! This happens with the servlet container I'm using, as well as TomCat 3.3.

  • Program or script to delay sending emails? - For late night workers

    Hi,
    I'm wondering if anyone knows how I can delay sending emails out. Sometimes I am up very early (4am) to work. I don't want these emails going out at such a weird hour so I need to find a way to tell the emails to go out at a specified time (ie. 8am).
    I don't think Mail has this option. I heard there are scripts out there but the ones I've tried are all out of date.
    Can anyone help? A script OR another decent email program would do

    I'm not aware of Mail having this option, either, but you can this this rather easily with iCal.
    In iCal, double click on a day, and choose Edit. As you look over the options for the New Event, click the alarm (by default, it says None), and scroll down until you see Email. Of course, you can choose the date and time of the future email according to your needs.

  • Re: (forte-users) Delays in data transfer..server-to-client

    I would try using DOM (distributed object manager) traces. trc:do:20 will
    give you information on each messages sent from and received by the
    partition. Levels are 1, 2, 5, 7, and 8, and trc:do:*:8 is very
    verbose. trc:do:20:1 may tell you what you want to know. trc:do:1:1 will
    give you a basic 1-line-per DOM event trace that may also be all you need.
    Communications manager traces will tell you about network and socket-level
    activity, but not about the sizes of the messages themselves. In addition,
    the operating system makes decisions about physical packet size and
    send/receive timing, so CM activities only generally map to actual network
    activity.
    -tdc
    iPlanet Integration Server Engineering
    At 09:24 AM 5/1/01 -0700, you wrote:
    All,
    We are experiencing delays in object transfer between server and client. The
    delays are longer with large objects (a single object with an array of objects
    that reflect the rows returned in a database) than small (ie: 10 rows vs 400).
    Does anyone have any (actual) experience using the various Forte' flags in
    order
    to show the actual size of the object/packets being passed between the server
    and client?
    We are using input/output between client and server, input on all the SO's
    within a partition. Response on the server side is good, roughly 6 seconds or
    so. The round trip fare however from the time the client makes the SO call to
    the time that it completes is in the 25-30 second range, leaving roughly 20-25
    seconds unaccounted for. I have brought in the network guys who are
    requesting
    the data size and packet information. I did not see what I am looking for
    using
    the trc:cm:*:4 and trc:cm:*:8 flags. I will be trying the trc:cm:*:10
    flag, but
    Forte' indicates that this flag is very verbose, the systems group hates
    it when
    I use up all of THEIR disk space!
    Any ideas would be appreciated as always.

    Jeff,
    If the object you are passing does not require changes made to it in the
    server partition to be returned, pass the object as copy input (pass by
    value not reference). If it is necessary to pass the object as input, try
    to pass only the attributes that are required to the remote partition
    instead of the whole object.
    Input/Output is normaly used with scalar variables. When a scalar is passed
    to a remote partition, if the value is changed in that partition, the value
    is not returned to the calling partition unless Input/Output is used.
    Input/Output should not be used for object type parameters, if you need to
    pass a reference, use Input only. If you can pass by value, use Copy Input.
    You will notice a huge difference in performance changing from Input to Copy
    input when passing large objects.
    Hope this helps,
    Travis Foote
    Fortedeveloper.com Inc.
    ----- Original Message -----
    From: "Jeff Bennett" <[email protected]>
    To: <[email protected]>
    Sent: Tuesday, May 01, 2001 9:24 AM
    Subject: (forte-users) Delays in data transfer.. server-to-client
    >
    All,
    We are experiencing delays in object transfer between server and client.The
    delays are longer with large objects (a single object with an array ofobjects
    that reflect the rows returned in a database) than small (ie: 10 rows vs400).
    >
    Does anyone have any (actual) experience using the various Forte' flags inorder
    to show the actual size of the object/packets being passed between theserver
    and client?
    We are using input/output between client and server, input on all the SO's
    within a partition. Response on the server side is good, roughly 6seconds or
    so. The round trip fare however from the time the client makes the SOcall to
    the time that it completes is in the 25-30 second range, leaving roughly20-25
    seconds unaccounted for. I have brought in the network guys who arerequesting
    the data size and packet information. I did not see what I am looking forusing
    the trc:cm:*:4 and trc:cm:*:8 flags. I will be trying the trc:cm:*:10flag, but
    Forte' indicates that this flag is very verbose, the systems group hatesit when
    I use up all of THEIR disk space!
    Any ideas would be appreciated as always.
    -jeff
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: [email protected]

  • For loop pause till event occurs

    I'd like to know if it's possible pausing for loop in a fixed step till en event occurs.
    I need to use for loop index to indexing some vector's data, but the steps in for loop must be exectuted only if  precise condition occurs.
    thank you very much for possible solutions
    Francesco

    Without seeing any code, it is hard to recommend what to do.
    You probably want a State Machine architecture so that you can stay in a certain state of a while loop, then move on to the next step (state) when your condition is met.
    You could also use event structures.  You could also use notifiers or occurrences to hold the execution of your loop until the notifier is written to or occurrence executed in a parallel loop of your code.

  • How to send data back to publishing stream

    Hi,
    Environment: ActionScript3.0, FMS, Flash Project created in Flash Develop
    How to send data back to publishing stream? I need to send data back to publishing stream.
    Using NetStream.send() we can send data to subscribers but is it possible to send data from subscriber back to publisher using any NetStream method.
    One other solution to this is remoteSharedObject, but if it is possible with NetStream class then let me know.
    Thanks

    There are a number of ways to extract data from CRM On Demand including:
    * Export - manual process, generate CSV file containing CRM On Demand data
    * List/Analytics - manual process, export the contents of a report of list to a CSV
    * Web Services - programmatic, develop an application that queries for data within CRMOD
    * Integration Events - programmatic, use workflow to trigger event creation and then poll for events to know when an operation occurs on a record (i.e. Insert of new Account record)
    As for getting that data into another system, that will depend on the system and the methods available for inserting data that it makes available.
    Hope this helps.
    Thanks,
    Sean

  • Disable "Send Data File" prompt

    When I open the pdf created in LiveCycle Designer 7.1 and click on "Submit to Email" it prompts me for what type of email app I use. It then presents the "Send Data File" prompt. The options are "Send Data File" "Print Form" and "Cancel." It also has a "Don't show again" checkbox.
    Is there a way to disable this prompt? For example after the user clicks on their email app it would simply open the email with the data file as an attachment.
    I'm afraid that my people may click on "Print Form" instead of "Send Data File" or they might click "Cancel". I just want to ensure this is as easy as possible for them to complete.
    Does anyone know if it's possible to disable the "Send Data File" prompt and automatically open an email and attach the data file?

    Amrit,
    I apologize for taking so long to respond to your question. It took me a while to locate someone on the Acrobat Team who could answer my questions.
    It's a good thing you asked about this because it turns out that this behaviour will no longer occur as of the next release of Acrobat. In the next release, if the call to submit a form's data via email comes from an Acrobat
    Action, the "Choose your email application" dialog will always be displayed (unless the user has already clicked on the "don't show this again" check box which you can't control programmatically). If, however, the call to submit the form's data comes from JavaScript, the dialog won't be displayed. Instead, Acrobat will use the system's default email application (e.g. Microsoft Outlook) to do the submission.
    Unfortunately, clicking on a button with the mouse or the keyboard (by setting focus to it and hitting the Enter key) as well as firing a button's Click event with execEvent("click"), as I had previously suggested, will all be considered Acrobat
    Actions and will therefore possibly show the unwanted "Choose your email application" dialog.
    In order to get around this, we need a solution which always uses JavaScript to do the submission. Fortunately, we can use the Acrobat Document object's
    submitForm method to do this, thereby ensuring that the unwanted dialog doesn't show-up in future versions of Acrobat. The only potential problem with this solution is that it'll only work if the form is rendered to PDF. If the form is rendered to HTML (using
    Adobe LiveCycle Forms, for example), this method will not work because Acrobat won't be involved in hosting the form.
    The trick is to use the
    event.target object in a regular button's Click event. This object is actually the Acrobat Document object. From there, you can use the
    submitForm method as follows in order to achieve the same behaviour as that of Designer's email submit button (in JavaScript):
    var sEmailAddress = "[email protected]";
    var sSubject = "This is an email";
    event.target.submitForm
      cURL: "mailto:" + sEmailAddress + "?subject=" + sSubject,
      cSubmitAs: "XML",
    I've attached a sample form which uses this JavaScript to submit its data via email. Give it a try to see how it works.
    Stefan
    Adobe Systems

  • DMVPN stops sending data

    Hello all.
    I'm using DMVPN tunnels in my network and all goes well, but few weeks ago a got some problem: two my DMVPN tunnels stop receveing any data until they were rebooted. I'm using 881G routers as spokes and 3945e as hub. I had tried google this problem, found the same questions and no answers. I hope i will get some help at Cisco Support Community.
    Config of hub (relevant parts):
    interface GigabitEthernet0/0.526
    description BeelineLokal
    encapsulation dot1Q 622
    ip address 10.200.1.49 255.255.255.192
    ip nat outside
    no ip virtual-reassembly in max-reassemblies 1024
    standby 2 ip 10.200.1.2
    ip tcp adjust-mss 1450
    no cdp enable
    end
    interface Tunnel2000
    description DMVPN for Beeline WAN Kiev
    ip address 10.1.160.1 255.255.255.0
    no ip redirects
    ip mtu 1400
    ip nhrp authentication *****
    ip nhrp map multicast dynamic
    ip nhrp network-id ***
    ip nhrp holdtime 10
    ip nhrp registration no-unique
    delay 500
    tunnel source 10.200.1.2
    tunnel mode gre multipoint
    end
    Spoke:
    interface FastEthernet4
    ip address 10.200.1.178 255.255.255.252
    duplex auto
    speed auto
    end
    interface Tunnel0
    description DMVPN for BeeLine WAN Ukraine
    bandwidth 1000
    ip address 10.1.160.** 255.255.255.0
    no ip redirects
    ip mtu 1400
    ip nhrp authentication ***
    ip nhrp map 10.1.160.1 10.200.1.2
    ip nhrp map multicast 10.200.1.2
    ip nhrp network-id ***
    ip nhrp holdtime 10
    ip nhrp nhs 10.1.160.1
    delay 100
    tunnel source FastEthernet4
    tunnel mode gre multipoint
    end
    debug from spoke:
    Jun 27 13:56:08.493: NHRP-ATTR:  Requester Ext Len: Total ext_len  with NHRP attribute VPE 56
    Jun 27 13:56:08.493: NHRP: Attempting to send packet via DEST 10.1.160.1
    Jun 27 13:56:08.493: NHRP: Encapsulation succeeded.  Sending NHRP Control Packet  NBMA Address: 10.200.1.2
    Jun 27 13:56:08.493: NHRP: Send Registration Request via Tunnel0 vrf 0, packet size: 108
    Jun 27 13:56:08.493:  src: 10.1.160.19, dst: 10.1.160.1
    Jun 27 13:56:08.493:  (F) afn: AF_IP(1), type: IP(800), hop: 255, ver: 1
    Jun 27 13:56:08.493:      shtl: 4(NSAP), sstl: 0(NSAP)
    Jun 27 13:56:08.493:      pktsz: 108 extoff: 52
    Jun 27 13:56:08.493:  (M) flags: "unique nat ", reqid: 69798
    Jun 27 13:56:08.493:      src NBMA: 10.200.1.166
    Jun 27 13:56:08.493:      src protocol: 10.1.160.19, dst protocol: 10.1.160.1
    Jun 27 13:56:08.493:  (C-1) code: no error(0)
    Jun 27 13:56:08.493:        prefix: 32, mtu: 17916, hd_time: 10
    Jun 27 13:56:08.493:        addr_len: 0(NSAP), subaddr_len: 0(NSAP), proto_len: 0, pref: 0
    Jun 27 13:56:08.493: NHRP: 132 bytes out Tunnel0
    Jun 27 13:56:08.493: NHRP: Resetting retransmit due to hold-timer for 10.1.160.1
    Before Cisco i'm using MS RRAS at my branch and all was fine.

    FAQ
    1. Best Effort Test: -provides background information.
    Download  Speed
    4.39 Mbps
    0 Mbps
    4 Mbps
    Max Achievable Speed
     Download speedachieved during the test was - 4.39 Mbps
     For your connection, the acceptable range of speeds is 1.2 Mbps-4 Mbps.
     IP Profile for your line is - 4.5 Mbps
    2. Upstream Test: -provides background information.
    Upload Speed
    0.82 Mbps
    0 Mbps
    0.83 Mbps
    Max Achievable Speed
    Upload speed achieved during the test was - 0.82Mbps
     Additional Information:
     Upstream Rate IP profile on your line is - 0.83 Mbps
    We were unable to identify any performance problem with your service at this time.
    It is possible that any problem you are currently, or had previously experienced may have been caused by traffic congestion on the Internet or by the server you were accessing responding slowly.
    If you continue to encounter a problem with a specific server, please contact the administrator of that server in the first instance.

  • Send data from applet to web server

    Hi,
    I want to send data(event notification) to resource through web server using url.
    Like,As long as perticular action or event is occuring I am sending that message to url.
    I reffered Sevlet theory uses HTTPMessage,but I am confused how should start and what would be feasible?
    Even when I run my code I am not finding browser.How should I place an applet in web server page?
    Regards,
    Palak
    Message was edited by:
    palak_shah

    Hi
    I agree usage of HttpClient is a better and a simple method.
    But If your Application Requirements are Simple you may go by using URL & URLconnection Objects in java.net package.
    Just to Add In You Can Checkout the links given below to have a better understanding of how the communication works...
    The Example APPLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.java.txt
    The Example SERVLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgServlet.java.txt
    and the Example AppletDemo Class
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.class
    Hope this helps :)
    REGARDS,
    RaHuL

  • How can i send data POST with a html link in a textfield

    Hello,
    This is my problem : I generate (from a php script) html
    links in a textfield. I would like for each link to send data with
    the POST method to an other script.
    My problem is that the getURL("lien", "", "POST") function
    can be use only by a movieclip or button event ... and not from a
    html link ...
    How can i do it ?
    Have you a small idea???
    Thanks ....

    yes, thanks but now my problem is in my function associated
    to this link :
    function SendPost()
    var toto="toto";
    getURL("
    http://127.0.0.1/board/scheduledfirst.php",
    "_blank", "GET");
    The function is executed but after in php i can get anything
    with echo ($_GET["toto"]); echo ($_POST["toto"]);
    Why ?

Maybe you are looking for

  • Is it possible to call a class in a jar file from JNI environment?

    Hi Is it possible to call a class in a jar file from JNI environment? Thanks in advance.

  • Problem updating payload

    Hi I am having trouble updating the payload of a task. Whatever I try, I get an exception saying that the parent 'task' node is read-only and so the 'payload' child node can't be updated. I have attached a sample stack trace (edited slightly for legi

  • Summarize in numbers for ipad

    I do not know how to summarize in numbers for Ipad. I can sort without a problem. However if I want to summarize, I cannot do it. Please help RLK

  • Human Workflow Notifications Emails - Turn these Off?

    All, We have built an application that uses Oracle BPM and sginificant number of Human Tasks. We have also configured the Email notifications to allow SOA to send emails through our generic fault framework. The issue we have is as a result of this, w

  • Clusterware 10gR2 10.2.0 Solaris 10x86 11/06 u3

    Hello all im trying to install clusterware on the above architecture & am receiving errors. tail -f -10 /oracle_cluster/product/10.2.0/crs/install/make.log make: Fatal error: Command failed for target `client_sharedlib' /usr/ccs/bin/make -f ins_net_c