How to send string data through socket!

Is there any method to send string data over socket.
and if client send string data to server,
How to get that data in server?
Comments please!

Thank for your kind answer, stoopidboi.
I solved the ploblem. ^^;
I open the source code ^^; wow~~~~~!
It will useful to many people. I spend almost 3 days to solve this problem.
The program works like this.
Client side // string data ------------------------> Server side // saving file
To
< Server Side >
* Server.java
* Auther : [email protected]
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Server extends JFrame
     private JTextField enter;
     private JTextArea display;
     ObjectInputStream input;
     DataOutputStream output;
     FileOutputStream resultFile;
     DataInputStream inputd;
     public Server(){
          super("Server");
          Container c = getContentPane();
          enter = new JTextField();
          enter.setEnabled(false);
          enter.addActionListener(
               new ActionListener(){
                    public void actionPerformed(ActionEvent ev){
                         //None
          c.add(enter, BorderLayout.NORTH);
          display = new JTextArea();
          c.add(new JScrollPane(display),
                 BorderLayout.CENTER);
          setSize(300, 150);
          show();
     public void runServer(){
          ServerSocket server;
          Socket connection;
          int counter = 1;
          display.setText("");
          try{
               server = new ServerSocket(8800, 100);
               while(true){
                    display.append("Waiting for connection\n");
                    connection = server.accept();
                    display.append( counter + " connection is ok.\n");
                    display.append("Connection " + counter +
                         "received from: " + connection.getInetAddress().getHostName());
                    resultFile = new FileOutputStream("hi.txt");
                    output = new DataOutputStream(resultFile);
                    output.flush();
                    inputd = new DataInputStream(
                         connection.getInputStream()
                    display.append("\nGod I/O stream, I/O is opened\n");
                    enter.setEnabled(true);
                    try{
                         while(true){
                              output.write(inputd.readByte());
                    catch(NullPointerException e){
                         display.append("Null pointer Exception");
                    catch(IOException e){
                         display.append("\nIOException Occured!");
                    if(resultFile != null){
                         resultFile.flush();
                         resultFile.close();
                    display.append("\nUser Terminate connection");
                    enter.setEnabled(false);
                    resultFile.close();
                    inputd.close();
                    output.close();
                    connection.close();
                    ++counter;
          catch(EOFException eof){
               System.out.println("Client Terminate Connection");
          catch(IOException io){
               io.printStackTrace();
          display.append("File is created!");
     public static void main(String[] args){
          Server app = new Server();
          app.addWindowListener(
               new WindowAdapter(){
                    public void windowClosing(WindowEvent e){
                         System.exit(0);
          app.runServer();
< Client side >
* Client.java
* Auther : [email protected]
package Client;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Client extends JFrame
     private JTextField enter;
     private JTextArea display;
     DataOutputStream output;
     String message = "";
     public Client(){
          super("Client");
          Container c = getContentPane();
          enter = new JTextField();
          enter.setEnabled(false);
          enter.addActionListener(
               new ActionListener(){
                    public void actionPerformed(ActionEvent e){
                         //None
          c.add(enter, BorderLayout.NORTH);
          display = new JTextArea();
          c.add(new JScrollPane(display), BorderLayout.CENTER);
          message = message + "TT0102LO12312OB23423PO2323123423423423423" +
                    "MO234234LS2423346234LM2342341234ME23423423RQ12313123213" +
                    "SR234234234234IU234234234234OR12312312WQ123123123XD1231232" +
               "Addednewlinehere\nwowowowwoww";
          setSize(300, 150);
          show();
     public void runClient(){
          Socket client;
          try{
               display.setText("Attemption Connection...\n");
               client = new Socket(InetAddress.getByName("127.0.0.1"), 8800);
               display.append("Connected to : = " +
                      client.getInetAddress().getHostName());
               output = new DataOutputStream(
                    client.getOutputStream()
               output.flush();
               display.append("\nGot I/O Stream, Stream is opened!\n");
               enter.setEnabled(true);
               try{
                    output.writeBytes(message);
               catch(IOException ev){
                    display.append("\nIOException occured!\n");
               if(output != null) output.flush();
               display.append("Closing connection.\n");
               output.close();
               client.close();
          catch(IOException ioe){
               ioe.printStackTrace();
     public static void main(String[] args){
          Client app = new Client();
          app.addWindowListener(
               new WindowAdapter(){
                    public void windowClosing(WindowEvent e){
                         System.exit(0);
          app.runClient();

Similar Messages

  • How to send encrypted data through XI. Pls advice urgent

    Hi All,
    There is some customer confidental information that I need to
    send from source system to XI and then to target system.
    So client wants that data to be encrypted.Source and Target system can be File System or can be wsdl files.
    Please send me blogs/docs how this scenario can be made.
    Regards

    Hi,
    For this if you use SOAP Scenarios means you can have the Security settings in the SOAP Adapter itself
    Please search in SDn on SOAP Adapters
    Regards
    Seshagiri

  • Hi friends, How to send any data (even binary) through XI, without using

    1) How to send any data (even binary) through XI, without using the Integration Repository .?

    hi ganga,
    Yes; 
    1. we can test adapters very easily and quickly without any IR development.
    2. we can send any formatted data without having to convert it to XML and back again, e.g. file->XI->file.
    3. we can send any document from 1 sender to multiple receivers using XI to guarantee delivery.
    /people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository
    the process integration layer of the NetWeaver  define/reuse interface objects for the SAP Integration Repository. These objects include Business Scenarios, Business Processes, Message Interfaces, Message Types, Data Types, Message Mappings, and Interface Mappings. The application developer refers to these objects in defining the interactive flow between applications for the SAP Integration Directory.
    regards,
    nikhil

  • How to assign a button for attachment and send the data through browser ?

    Hi friends,
    How to convert to browser ?
    how to assign a button for attachment and send the data through browser ?
    Thanking you.
    Regards
    Subash.

    Refer to
    How to create a text box in ascreen painter?
    where another user (venkateshwar reddy) has asked a very similar question...
    Jonathan

  • How to send the data from mac pc to External drive

    how to send the data from mac pc to External HDD
    or Pen Drive but with out deleting the preview as data

    You can use "Finder", which is in your dock, to copy files from your iMac folders over to the external hard drive.
    Hope this helps

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • How to send a mail through web dynpro application

    Hi
    How to send a mail through web dynpro application?
    Thanks

    Hi ,
      Please post some more details about your query .
    One way is to can use LinkToUrl UI element and in the reference property of the UI element , give it as mailto:mail addess
    Thanks.
    aditya.

  • How to send the data manually

    Hi Experts,
      I need small information.when messages are gone into queue state due to one message 
    When an EDI file came into wrong format and with that some messages are gone into queue state in MONI.
    if i cancel the first message then remaining all the messages are processing successfully.
    So from that cancel message i want sent the data manually as business needs that data.
    Can all please tell  me how to send the data manually with steps.
    Thanks in Advance.
    Bhaskar

    Hi,
    I think you are talking about QoS "EOIO", in which all messages are porcessed in FIFO order and whenever the preceeding message get stuck due to error in the queue, then all the messages are stoped. And yes as soon as you will cancel the message which went into error all the remaining messages will automatically will be delivered.
    In my opinion since QoS is EOIO then it will be not possible to sent the data mannually, you can do one thing, do not cancel the message. Try to correct the messge and then resend it.
    Regards,
    Sarvesh

  • How to connect oracle data through BlazeDS in flex 4

    How to connect oracle data through BlazeDS in flex 4

    Hi
                   If u want to connect to the database oracle just paste the Ojdbc14.jar file into the lib folder of blazeds project..
                             Normally blazeds distribution version contains blazeds.war file... upload that war file to the tomcat or any other application server..
                          u will get the build path and in lib folder paste the ojdbc14.jar file to connect to the oracle and do u r stuff at server side java ....
                      if this will reslove ur problem please mark as answered..

  • Sending String Data of  64 kilo bytes to Remote Function Module

    Hi,
        I have an RFC call from JAVA and I need to send string data to the FM. The maximum size of the data that I can send from java is 64 kilo bytes (Functional requirement). I want to receive this data as a table's parameter in the FM. Table's parameter’s data type can only be structure's which are FLAT-LINED. So if I use STRNIG as the data type for receiving the data from JAVA the RFC doesn’t allow me (As this makes the structure NON FLAT LINED which RFC will not allow as data type for tables parameter). So I have to use some other data type like CHAR or LCHR. But the maximum size for CHAR and LCHR is around 32 kilo bytes. I need a way to receive 64 kilo bytes of data into the Function Module as a table’s parameter.
    Thanks in advance
    Sesh

    Hi!
    I think I was pretty near your problem. When talking about table fields, you could a 'parameter' -> field of your table parameter.
    Which type? String is out of question, because here length is variable, but you need a constant length definition. I just have a look into help of data, built in ABAP-types. Here C and N can have a length from 1 to 65535 - OK, not 64 KB but only 1 byte missing...
    ... just made a small test, there is a second border (for non-unicode systems): the total length of the structure can't exceed 65535. If you need additional fields, define a second table parameter and place your additional fields in a second table. You can't define a link field (would need some space), so you have to go for a '1st line of data matches 1st line of attributes'-definition.
    I'm still a little bit curious: what kind of data you are sending?
    Regards,
    Christian

  • Send a message through socket

    Hi
    I want to send a MIMEMessage through socket. And want to receive the same.
    Could any one help me out ?

    Hi
    I proceed that thing.
    I am getting the problem while converting the input stream from socket to MIME message.
    I am getting prob at following line.
      //soc is the object of Socket
      Session session =Session.getDefaultInstance(new Properties(), null);
      MimeMessage l_msg = new MimeMessage(session, soc.getInputStream());When I read the input stream from the file.
    It works successfully. But when I try to get it from socket not doesn't work.
    It's not showing any error also. So I am not able to track the actual error.
    Could you please tell me why it is not working.
    Thanks
    Anmolb

  • Send a image through socket method getoutputstream

    cani send an image through socket methods instead of send a txt

    1) Use the search feature, or look back a couple of pages, this question was asked sometime yesterday
    2) In all the many times that it's been asked, no-one denies it but at the same time no-one's posted any code to do it (AFAIK) I'd be interested too if anyone does find a way...

  • I need to find out how much wifi data my apps are using. I have a very limited amount of wifi data, and I am exceeding my monthly allowance. Apparently, even apps I think are not open are sending/receiving data through the wifi and using up my allowance.

    I need to find out how much wifi data my apps are using. I am on a very limited amount of WiFi data each month, which I am regularly exceeding. I have been told to work out which of my apps is using the data. Also, I think I have closed an app by double clicking the home button, then swiping the app up - is this the way to close it, or will it still be sending/receiving data?

    Go into your Settings : General : and turn off background refresh for your apps.  In Settings : Mail  turn Fetch new data to OFF and Load Remote Images to OFF.  This will mean that Mail will only check for messages when you actually use it, and all your advertising junk mail won't have all the images in it.
    Turn off push notifications every chance you get.
    Make sure you are actually quitting apps:  to quit apps press the Home button twice and you should see a bunch of smaller screen images for every open app.  To quit the app swipe from the screen image (not the icon) upward off the top of the iPad.  You can swipe left and right to see more open apps, but there must be no left-right movement on the screen when you swipe upward to close the app.
    Turn off your internet connection when you do not need it.  The easiest way to do this is to swipe up from the bottom of you screen to get the control centre, and then touch the airplane to turn on airplane mode.  You can repeat this sequence to turn it back on again when you need it.  Most especially turn airplane mode on whenever you are sleeping your iPad for long periods.  This will save battery life too.  OR actually turn your iPad off - which means holding the power key down for several seconds until the red swipe bar appears, and then swipe to turn it off.  If you go this route, note that it will take longer to turn on then it takes to wake from sleep.

  • How to send joystick data over TCP connection

    Hi all,
    I am a long time Labview discussion forum user for learning, but this is my first time posting a question, I hope somebody can help me!
    In the attached VI I am trying to send data from a joystick over a TCP connection. I can send data fine using the TCP examples (in fact the majority of my VI is just a copy of the example). However I am to the point where I do not know how to send all the data necessary (3 axis data, 12 buttons, and the POV data) over TCP. Strings, clusters, and arrays were never my strong suite and converting between them is a nightmare for me.
    Basically I am trying to send each axis data (X,Y, and Z), button data (12 buttons), and POV data (the POV data will be calculated to adjust the position of a camera, so the immediate data is not important, I will add functions to add the change in the button movements to write a standing position for two servos [pan and tilt], for which that I will need to send over the TCP connection) over the TCP connection to control various cameras and motors. I don't know if it is posible to send that much data over a TCP connection in one write VI through a string, and also how to separate the string on the other side in order to control the client VI.
    Again, the actual TCP communication I get, and can operate fine, just formatting all the data into a string (or whatever is required) so that I can unpack on the other side is the issue here.
    Another question I have (not impotant to get the program running just might make it easier on me) is can a TCP server (which sends the data to the client) also recieve data back from the client on the same port ( for example sensor data and digital positions [on,off])? Or do I need to set up two TCP communication loops with the first client acting as the server on a different port than the first, which then sends the data to the original server, which also has a client TCP configuration in another loop? I hope this makes sense...
    One final question.....I already have a solution to this but using labview for the entirety of this project would be nice. I use skype to stream 1080p video from a webcam to my computer so I can view live feed. Can labview do this? This would be awesome if so, I am just not sure if the communication protocols in use could support real time (or as close as possible to streaming) for 1080p video.
    Thanks all in advance for your help,
    Physicsnole
    Attachments:
    cameraserver.vi ‏24 KB
    cameraclient.vi ‏18 KB

    Physicsnole wrote:
    In the attached VI I am trying to send data from a joystick over a TCP connection. I can send data fine using the TCP examples (in fact the majority of my VI is just a copy of the example). However I am to the point where I do not know how to send all the data necessary (3 axis data, 12 buttons, and the POV data) over TCP. Strings, clusters, and arrays were never my strong suite and converting between them is a nightmare for me.
    Well, you cast the axis info cluster to a string, but then you cast it back to an array of DBL. Thatr's not compatible. You should probably cast it back to an "axis info" cluster of exactly the same type. Go the the other VI and right-click the cluster wire to create a constant. Now move that diagram cluster constant to the other VI and use it as type.
    Your default ports don't seem to match. You seem to have client and server roles confused. In the sever you create a listener, but then you start sending packets, even though no connection is established. The connection needs to be initiated by the client.
    Your client stops the loop the first time a timeout is encountered. Shouldn't that be more permanent? Also, please retain code clarity and avoid unecessary complexities. For example, replace the "not or" with a plain "or" and change the loop to "stop if true"
    Physicsnole wrote:
    Basically I am trying to send each axis data (X,Y, and Z), button data (12 buttons), and POV data (the POV data will be calculated to adjust the position of a camera, so the immediate data is not important, I will add functions to add the change in the button movements to write a standing position for two servos [pan and tilt], for which that I will need to send over the TCP connection) over the TCP connection to control various cameras and motors. I don't know if it is posible to send that much data over a TCP connection in one write VI through a string, and also how to separate the string on the other side in order to control the client VI.
    You can send as much as you want. The casting to/from string is the same as described above.
    Physicsnole wrote:
    Another question I have (not impotant to get the program running just might make it easier on me) is can a TCP server (which sends the data to the client) also recieve data back from the client on the same port ( for example sensor data and digital positions [on,off])? Or do I need to set up two TCP communication loops with the first client acting as the server on a different port than the first, which then sends the data to the original server, which also has a client TCP configuration in another loop? I hope this makes sense..
    The primary function of a "server" is to wait for a connection and then communicate with the client once a conenction is established. An established TCP/IP connection is fully two-way and both sides can send and receive.
    LabVIEW Champion . Do more with less code and in less time .

  • How to send Array data using Post Method?

    Var array = $_POST['myData'];
    array[0] => 'ABC'
    array[1] => 'DEF'
    how to improve this code to support send array data...?
    String url ="http://xxxxx/test.php";
    String[] arraystr={"ABC", "DEF", "EDFF"}
    String parameter = "myData=" +arraystr;    // no support this
    Strint str = postMrthod(url, parameter );
    public static String postMethod(String url, String parameter) {
            StringBuffer b = new StringBuffer("");
            HttpConnection hc = null;
            InputStream in = null;
            OutputStream out = null;
            try {
                hc = (HttpConnection) Connector.open(url);
                hc.setRequestMethod(HttpConnection.POST);
                hc.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
                hc.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
                out = hc.openOutputStream();
                byte postmsg[] = parameter.getBytes();
                for (int i = 0; i < postmsg.length; i++) {
                    out.write(postmsg);
    out.flush();
    in = hc.openInputStream();
    int ch;
    while ((ch = in.read()) != -1) {
    b.append((char) ch);
    } catch (IOException e) {
    e.printStackTrace();
    try {
    if (in != null) {
    in.close();
    if (hc != null) {
    hc.close();
    } catch (IOException e) {
    e.printStackTrace();
    return b.toString().trim();

    yes, you can send integer value like this. But I think you have to put quotes around <%= TAMID%> i.e.
    <input type="hidden" id="HTTP_CVHTAMID"
    name="HTTP_CVHTAMID" value= "<%= TAMID%>" >

Maybe you are looking for

  • Partial payment for Vendor down payment request

    Hi Gurus How to do partial payment for vendor down payment request  using F-48 If i enter partial amount next time same request is not appearing in the list. Pls guide me. Reply will be appreciated with full points Thanks in advacne Sneha

  • Down Payment Request  - Reconciled

    Hi My location is Chile point to consider is the following: In 2005 A: Down Payment Request documents are created, then pay and then can be reconciled with other documents such as invoices. In 2007 To: the down payment request and can not be reconcil

  • Delete record error really bad...need help

    Hi, I am trying to delete a record but the process is taking too long then it crashes mysql and give this: Warning: mysql_connect() [function.mysql-connect]: Can't connect to  MySQL server on 'localhost' (10048) indb.php on line 9 Fatal error: Can't

  • Options-content- exceptions is NOT working. I put a website on exception list but doesn't work

    I go to : Tools, options, content. it has on top: Load images automatically . it has a button: exceptions. I enter a web site there so it will NOT load images automatically- does NOT work. OR I un-click the load images automatically which makes ALL w

  • AT LINE SELECTION AN AT USER-COMMAND IN ONE REPORT

    hiiii friends..... hw  can i go for both at line selection an at user comond in one report.... ie if double click on basic list it should shw sm output an when i choose menu optoin it should perform sm other output......