Decoding character received on a socket

Hello,
My Java program is reading a byte array containing a word with
special characters (>127) -> Oxe9 for &eacute.
I saw that the TCP packet was right using the tcpdump with hexa view.
My default encoding charset is Latin-1 (ISO-8859-1), the one I think
being good :-| (System.setProperty("file.encoding", "ISO-8859-1");)
When doing a System.out.println with the word converted into a
String (new String(myArray, "ISO-8859-1")), the special character
isn't properly converted... I see a ? instead of a &eacute
Help me please ':-|
Ludovic

System.out.println goes to your terminal/console, right?
Are you sure your terminal can display the special char???
I'd try to do the debug output using JOptionPane.showMessageDialog

Similar Messages

  • Fieldpoint write.vi error - 33816 (Unexpected character received from Optomux response)

    Hi, I have been running a program for a few months now and yesterday I got an error at the fieldpoint write.vi error - 33816 (Unexpected character received from Optomux response). The program will run fine for approx. 5 minutes and then the error occurs, if I click continue the program will run fine again for another 5-10 minutes before occuring again. The field point module that is being affected is a digital output which is controlling a relay connected to a heating element. When the error occurs it freezes the program and if the relay happens to be on it can cause a potentially dangerous over temperature event. Luckily I happened to be in the room when it first occured but the program is supposed to rund 24-7. I tried taking off automatic error handling but that caused the program to run incorrectly.
    What is causing this error ?? Why did it just materialize ? How can prevent it from happening again ?
    Any insight would be greatly appreciated !

    beaster wrote:
    Hi, I have been running a program for a few months now and yesterday I got an error at the fieldpoint write.vi error - 33816 (Unexpected character received from Optomux response). The program will run fine for approx. 5 minutes and then the error occurs, if I click continue the program will run fine again for another 5-10 minutes before occuring again. The field point module that is being affected is a digital output which is controlling a relay connected to a heating element. When the error occurs it freezes the program and if the relay happens to be on it can cause a potentially dangerous over temperature event. Luckily I happened to be in the room when it first occured but the program is supposed to rund 24-7. I tried taking off automatic error handling but that caused the program to run incorrectly.
    What is causing this error ?? Why did it just materialize ? How can prevent it from happening again ?
    Any insight would be greatly appreciated !
    I believe Optomux was used for the serial connection scheme (please correct me if I'm wrong) so we are looking for something that could corruprt the serial comm.
    Quick Test:
    Try disconnecting the relay and run the program without the heater and external circuitry to rule out glitches etc.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Seeburger sFTP receiver adapter error: Socket Write Error, EOF Received

    Hello experts,
    We have a sFTP to sFTP scenario for which we are getting below error every time the scenario is executed.
    Error Messages are as follows:
    Put File: Could not connect to remote host, Reason: Unexpected termination; software caused connection abort; socket write error[unknown cause].
    Sometimes below error occurs :
    Put File: Could not connect to remote host, Reason: EOF received from remote side [unknown cause].
    Every time after restart of sFTP adapter on XI box, failed messages are sent successfully to receiver sFTP server.
    There is no error for sender sFTP channel. This error occurs only for the receiver sFTP channel.
    On receiver sFTP side, we are using Public key-private key authentication.
    Can anyone please let me know what could be the cause of connection failure. ?
    Thanks a lot in advance!
    (I searched many threads on SDN but could not find anything relevant to this particular situation, so posting a separate question.)
    Minal

    Thanks Naveen for the reply..
    I missed to mention that we are working on XI3.0 with SP19 and seeburger sFTP is 1.7.4
    Looks like key exchange is working properly as after every restart of adapter all failed messages are processed successfully..
    It is observed that if there is an idle time of 8-10 hours between last data transfer and current data transfer then this error occurs.
    We have increased connection timeout and transmission timeout parameters also for sFTP properties in visual admin.
    Thanks,
    Minal
    Edited by: Minal Vaidya on Oct 5, 2011 8:46 AM

  • Receiving Image via socket and creating via byte[]...

    Hi Folks...
    I�m trying to send a WebCam SnapShot to my Midlet running in a PDA via socket..
    The method used to send the Image is:
    BufferedImage img = toBufferedImage( getScreenShot( getFrameBuffer() ) );
              byte[] buf = convertImage( toBufferedImage( img ) );
              BASE64Encoder enc64 = new BASE64Encoder();
              enc64.encode(buf);
              try {
                   out.writeUTF("IMAGEM");
                   out.writeInt( buf.length );
                   out.write( buf );
              } catch (IOException e) {
                   e.printStackTrace();
              }So this code get a snapShot from the webCam and returns a BufferedImage. This BufferedImage is converted to a byte[], and later this byte[] is encoded in Base64 format with BASE64Encoder.
    In the next step the buffer is sent to the client, the server send the message "IMAGEM", in the sequence the size off the byte[] and then the byte[].
    The code that receive the Image byte[]...
    private void receiveImageAction(){
              byte[] buf;
              try {
                   buf = new byte[ in.readInt() ];
                   in.read(buf);
                   Image img = Image.createImage( buf, 0 , buf.length );
                   viewForm.setMsg("Image created");
                   viewForm.setImageView(img);
              } catch (IOException e) {
                   viewForm.setMsg( "" + e.toString() );
              }catch(Exception e){
                   viewForm.setMsg( "" + e.toString() );
         }When the connection manager receives a message "IMAGEM" the function receiveImageAction is called.
    It receives the size off the byte[] and then receive the array.
    When I try to create the image using Image.createImage( byte[], int, int ) the exception IllegalArgumentException is throwed...
    The exception doesnt have a message...
    What is wrong ?
    Is the format off my image sent ?
    Is my buffer been encoded correctly by the BASE64Encoder class ?

    Will u try with replacing this line
    Image img = Image.createImage( buf, 0 , buf.length );with this line
    Image img = Image.createImage( buf, 0 , buf.length-1 );

  • How to pass and receive byte[] via socket

    Hi All,
    How can I pass a byte[] from client socket to the server socket.
    Also how to receive that bye[] at the server socket.
    Thanks and best Regards,
    - Lasith.

    Hi All,
    Thanks for replying my topic, but still I need some help regarding this.
    My requirement is to have client and server socket programs with following functions (this is bit related to cryptography as well :)).
    First I generate public and private keys for server and in the client side generating a random number and encrypt it with servers public key and sends to server.
    Please refer following code segment.
    SecureRandom random = new SecureRandom();
              long challange = random.nextLong();     
              Cipher cipher = Cipher.getInstance("RSA");
              cipher.init(Cipher.ENCRYPT_MODE, key, new SecureRandom());
                 byte[] cipherText = cipher.doFinal(new Long(challange).toString().getBytes());
                 String cipherTextToServer = cipherText.toString();Then I am passing this string to server socket as follows,
    if(cipherTextToServer !=null)
                   out.println(cipherTextToServer );The server should take this text and decrypt it as follows.
         PrintWriter out = new PrintWriter(client.getOutputStream(),true);
              BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    while((fromClinet  = in.readLine()) != null){
                   System.out.println("Server -> "+fromClinet);
                   System.out.println("Server -> "+*getDecriptedMassage*(fromClinet,prvKey));
                            out.println(Utility.getDecriptedMassage(massage,prvKey));
         public String getDecriptedMassage(String massage,Key key) throws Exception{
              Cipher cipher = Cipher.getInstance("RSA");
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] plainText = cipher.doFinal(massage.getBytes());
            System.out.println("plain : " +new String(plainText));
             return plainText.toString();
         }When running the program I am getting following error.
    Exception in thread "main" java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(Unknown Source)
         at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
         at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
         at sun.nio.cs.StreamDecoder.read(Unknown Source)
         at java.io.InputStreamReader.read(Unknown Source)
         at java.io.BufferedReader.fill(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at Client.main(Client.java:46)
    As my investigation if I can remove following code segments then program is working fine.
    System.out.println("Server -> "+*getDecriptedMassage*(fromClinet,prvKey));
    out.println(Utility.getDecriptedMassage(massage,prvKey));So this should be a error when decrypting message. If I am further explaining this the sending encrypted message with client is not same as getting decrypted message on server. Because of this program is giving the error.

  • Help: Send and Receive through Datagram Socket

    I am trying to create a client/server using Datagram Socket (UDP) as communication. I have a Recive and a Send class that implements runnable and are responsible for receiving and sending of message. I have two other classes Server and Client that are utilizing these. Now i can get the receive and send to work fine, but i am having trouble retrieving the message from the receive thread that i created in each of server/client. I've tried inserting a method so the server/client can call on to get the message (Receive.Get_Message()) but unfortunately this isn't working as i wanted. Since my server and clients are not implemented as runnables, i can only issue the command in some serialize fashion. What i really want to do is that whenever the message is receive by the Receive thread, it will immediately be send back to server/client and display right then, independent of what i was doing. (i have a command interface for S/C so it just sits there to wait for command, now what i would like is to have the S/C display the message it gets immediately after it gets it even when it's waiting for user input. since my program is waiting for a command, i really could not use the method describe above to achieve this) Could anyone help me with this?
    Thanks!
    Hung-Hsun Su

    u cant use the observer pattern. or at least i can't figure out how to implement it with sockets.
    you should use threading.
    public void run()
      while(true)
         //keep reading from socket
         InStream output = socket.getInputStream();
         InputStreamReader ir = new InputStreamReader(output)
         BufferedReader reader = new BufferedReader(ir);
         String s = null;
         while(s == null)
           s = reader.readLine();
         //then do whatever you want to the received string "s"
    }

  • Detect packet received using TCP sockets

    Hello:
    I was wondering if there was a way to detect if a packet has been sent to my socket. I know this sounds strange but here is what i want to do...
    I would like to do some processing on a render(distributed raytracing) while also waiting for a packet to be received over tcp ip. If i use .getInputStream() it just sits there at that line of code waiting for a packet. I would like to do some rendering and every now and then check to see if a packet has been sent. Is this possible? Or should i do this a totally different way? Thanks for your help!
    [email protected]

    Threads.
    One thread renders, the other threads blocks on the socket waiting for new information.

  • Problem with receiving message over socket

    class TCPClient5 {
    public static void main(String argv[]) throws Exception
    java.io.InputStream s = null;
    java.io.InputStreamReader r = null;
    try {
    URLConnection uc = new URL("http://www.countryflower.com/Country_Flower_Home_Pic.jpg").openConnection();
    s = uc.getInputStream();
         System.out.println(uc.getContentLength());
    int x = uc.getContentLength();
    BufferedInputStream buffer = new BufferedInputStream(s);
    File f = new File("c:\\Users\\dell\\Desktop\\image\\image.jpg");
    DataOutputStream outdata = new DataOutputStream(new FileOutputStream(f));
    int n = 0;
    while(true) {
    n = s.read(byte[x] buffer,0,buffer.length); ----- here I am getting error
    if (n == -1) break;
    if (n == 0) {Thread.sleep(50); continue;}
    outdata.write( buffer,0,buffer.length);
    outdata.close();
    finally {
    //if (b != null) b.close();
    if (r != null) r.close();
    if (s != null) s.close();
    In above code I am getting error .................
    I am unable to receive message from server..........Please help me with code

    n = s.read(byte[x] buffer,0,buffer.length); ----- here I am getting errorHere we are unable to read your mind. What error? The syntax you've typed isn't correct, is that really what you have?
    if (n == -1) break;
    if (n == 0) {Thread.sleep(50); continue;}'n' can never be zero. Omit this line.
    outdata.write( buffer,0,buffer.length); That should be outdata.write(buffer, 0, n);

  • How do i call recieve function automatically on when certain character receive on terminal

    i m using
    installComCallback
    function but function is not calling on recieving certain character. i simply want to get data continuously and disply the whole packet and then want to seperate ceratain data from that. i use the event character and i selected the character CR. i m sending 29 bytes packet from labwindows application and reciveing this packet and i used installcomcallback function and used evencharacter. but the function is not recieving
     

    Hi khadimhussain,
    There is very little useful information here.  Could you please provide a detailed description of your application (with context: I need to know why you are doing what you are doing not just what you are doing) and what you want to accomplish with the installComCallback function as well as either screenshots or an actual copy of your code? It will be very difficult to debug your code without being able to see how you are implementing it.  

  • Not able to send euro character ' €' via socket

    OS : Solaris - The solaris login profile is set with LC_CTYPE, LC_CTYPE, LC_LANG=ISO-8859-15 and we are able to see this when we run the set command and also locale in solaris.
    JRE : 1.6
    Application deployed in Weblogic 10.3
    I m trying to send a euro character in java via socket, but in the receiving end not able to receive properly. Even I have to tried to set the Charset ( in the java code )
    as ISO-8859-15 , but still it didn't work properly. Code snippet for the sample program to display euro symbol
    import java.io.UnsupportedEncodingException;
    import java.nio.charset.Charset;
    public class Euro {
    public static String createString( byte[] bytes, String enc )
    String CResult = null;
    try {
    CResult = new String( bytes, enc );
    } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
    return CResult;
    // ISO8859-15 is same as ISO8859-1 but with EUR character
    public static String createStringISO8859_15( byte[] bytes )
    String CResultISO = null;
    CResultISO = new String( bytes, Charset.forName("ISO-8859-15" ));
    return CResultISO;
    public static void main(String[] args) throws Exception {
    //String enc = "€";
    byte[] iso8859_15 = { (byte) 0xA4 }; // euro sign
    //byte[] iso8859_15 = "0xA4".getBytes(); // euro sign
    /*     String Cresult = Euro.createString (iso8859_15, enc);
    System.out.println("createString Result : " + Cresult);*/
    String CresultISO = Euro.createStringISO8859_15(iso8859_15);
    System.out.println("createStringISO8859_15 Result : " + CresultISO);
    When I 'm running the above code in windows it is working fine whereas in Solaris it is not working. The console just displays ?, rather than the actual '€' symbol. Is this a display problem in console of vt100 or porgramming? Kindly suggest. How to make this work in Solaris.

    Please repost or edit that mess with {noformat}{noformat} tags and proper indenting so it can actually be read.
    And then explain what sockets have to do with the price of fish.                                                                                                                                                                                                                                                                                                                                                                                   

  • Getting a request in a non English character

    Hi ,
    In an attempt to solve a problem of getting a request in a non English character , i use the code , taken from O'Reilly's "Java Servlet programing" First edition:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class MyServlet extends HttpServlet {
         public void doGet(HttpServletRequest req, HttpServletResponse res)
                                                                               throws ServletException, IOException {
              try {
                                                      //set encoding of request and responce
         req.setCharacterEncoding("Cp1255"); //for hebrew windows
         res.setCharacterEncoding("Cp1255");
         res.setContentType("Text/html; Cp1255");
         String value = req.getParameter("param");
                                                      // Now convert it from an array of bytes to an array of characters.
         // Here we bother to read only the first line.
                                                      BufferedReader reader = new BufferedReader(
         new InputStreamReader(new StringBufferInputStream(value), "Cp1255"));
                                                      String valueInUnicode = reader.readLine();
              }catch (Exception e) {
              e.printStackTrace();
    this works fine , the only problem is that StringBufferInputStream is deprecated .
    is there any other alternative for that ?
    Thanks in advance
    Yair

    Hi Again ..
    To get to the root of things , here is a servlet test and an http client test which demonstrates using the above patch and not using it :
    The servlet :
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.io.StringBufferInputStream;
    public class Hebrew2test extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              request.setCharacterEncoding("Cp1255");
              response.setCharacterEncoding("Cp1255");
              response.setContentType("Text/html; Cp1255");
              PrintWriter out = response.getWriter();
              String name = request.getParameter("name");
              //print without any patch
              out.println(name);
              //a try with patch 1 DEPRECATED
              out.println("patch 1:");
              BufferedReader reader =
              new BufferedReader(new InputStreamReader(new StringBufferInputStream(name), "cp1255"));
              String patch_name = reader.readLine();
              out.println(patch_name);
              //a try with patch 2 which doesn't work          
              out.println("patch 2:");
              String valueInUnicode = new String(name.getBytes("Cp1255"), "UTF8");
              out.println(valueInUnicode);
    and now for a test client :
    import java.io.*;
    import java.net.*;
    public class HttpClient_cp1255 {
    private static void printUsage() {
    System.out.println("usage: java HttpClient host port");
    public static void main(String[] args) {
    if (args.length < 2) {
    printUsage();
    return;
    // Host is the first parameter, port is the second
    String host = args[0];
    int port;
    try {
    port = Integer.parseInt(args[1]);
    catch (NumberFormatException e) {
    printUsage();
    return;
    try {
    // Open a socket to the server
    Socket s = new Socket(host, port);
    // Start a thread to send reuest to the server
    new Request_(s).start();
    // Now print everything we receive from the socket
    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream(),"cp1255"));
    String line;
    File f = new File("in.txt");
    FileWriter out = new FileWriter(f);
    while ((line = in.readLine()) != null) {
    System.out.println(line);
    out.write(line);
    out.close();
         catch (Exception e) {
    e.printStackTrace();
    class Request_ extends Thread {
    Socket s;
    public Request_( Socket s) {
    this.s = s;
    setPriority(MIN_PRIORITY); // socket reads should have a higher priority
    // Wish I could use a select() !
    setDaemon(true); // let the app die even when this thread is running
    public void run() {
    try {
                        OutputStreamWriter server = new OutputStreamWriter(s.getOutputStream(),"cp1255");
                        //String query= "GET /userprofiles/hebrew2test?name=yair"; //yair in Englisg ..
                        String query= "GET /userprofiles/hebrew2test?name=\u05d9\u05d0\u05d9\u05e8"; //yair in hebrew - in unicode
                   System.out.println("Connected... your HTTP request is sent");
                        System.out.println("------------------------------------------");
                        server.write(query);
                        server.write("\r\n"); // HTTP lines end with \r\n
                        server.flush();
                        System.out.println(server.getEncoding());
         server =      new OutputStreamWriter(new FileOutputStream("out.txt"),"cp1255");
                        server.write(query);
                        server.flush();
    catch (Exception e) {
    e.printStackTrace();

  • CTRL-M (^M) characters in data read from sockets

    Hi,
    We have developed a software applications which opens upto 300 TCP connections and 4000 UDP sockets. The data from the TCP application is multiplexed to UDP sockets and viceversa.
    We connect to the application using a TCP socket and send certain data to the application which in turns sends this data to all the 4000 UDP sockets. The data received from 4000 UDP sockets is in turn sent back to the TCP socket as responses.
    We used telnet to connecct to thespecific TCP port on our application, sent a request to be sent to all 4000 UDP sockets and noticed ctrl-M characters in the data received from TCP socket. However we are sure we are not appending or adding this ctrl-m character while sending the data on TCP socket.
    telnet host port >/tmp/abc
    send a request
    send next request
    (after 10 mins, close connection)
    cat -vet /tmp/abc >/tmp/xyz
    There are ctrl-m characters in /tmp/xyz.
    ^M is observed only at the end of few lines and not on all lines. Successive repeatition of this test generates ^M in different lines but at the end of the line always.
    Can anybody help me to know why these ^M characters are getting generated?
    Note: We are completely working on Solaris and do not move contents across Windows and Unix. Our application is completely written on C++
    Thanks.
    Message was edited by:
    shekhnam

    I think I've misunderstood something here. The problem you're having is with the response being filtered by Telnet or your client, not what telnet is sending to the server?
    In that case I think the explanation is clear. Telnet is trying to display what comes back on a screen, and it is deleting and inserting newlines every now and then according to its internal whim so as to make the data wrap. I don't know if you can control that, but I also don't know if it matters as long as you have your own client application. You just have to stop treating Telnet as a viable test client.

  • Decoded The Image File

    Dear,
    Actually I just wanna know how to sent a image file through Internet to recipients. Am doing a project regards the " Java electronic greeting card" And i use socket programming in the Sent module.
    thank you
    from
    vaniceberry

    An efficient way to do this, is to encode your BufferedImages as JPEG's before sending it over a socket connection.
    Assuming that "os" is the OutputStream of your socket connection, this would be the sender code:
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
    encoder.encode(screenShot);
    The receiver side has to decode the received image ("in" is InputStream of the socket connection):
    JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
    BufferedImage img = decoder.decodeAsBufferedImage();
    To use JPEG encoding/decoging features, you have to import com.sun.image.codec.jpeg.*

  • Unable to receive multicast on a multi network interface host

    Can anyone please help?
    I am not able to receive multicast on a multi network interface host.
    This is the code:
    public class LegacyMulticast {
    public static void main(String[] args) throws IOException {
    InetSocketAddress group = new InetSocketAddress("224.10.20.30", 12345);
    NetworkInterface iface = NetworkInterface.getByName("eth3");
    MulticastSocket socket = new MulticastSocket();
    socket.setSoTimeout(5000);
    socket.joinGroup(group , iface);
    byte[] b = new byte[4096];
    DatagramPacket datagram = new DatagramPacket(b, b.length);
    try {
    socket.receive(datagram);
    System.out.println("Success");
    catch (SocketTimeoutException ste) {
    System.out.println("Failure");
    socket.leaveGroup(group, iface);
    The funny thing is that when I start this code, Wireshark detects IGMP join on the correct network interface caused by joinGroup call, followed by constant UDP traffic on correct port which I aim to receive and finally I see correct IGMP leave caused by leaveGroup call and the UDP traffic stops.
    I just don't receive anything on socket.receive call.
    I am trying to figure this one out for days now. Pls help someone :)
    P.S. I suspected security, but System.getSecurityManager() call returns null.
    P.P.S. I also tried implementing this with NIO, but with same result.

    public class LegacyMulticast {
    public static void main(String[] args) throws IOException {
    InetSocketAddress group = new InetSocketAddress("224.10.20.30", 12345);
    NetworkInterface iface = NetworkInterface.getByName("eth3");
    MulticastSocket socket = new MulticastSocket(12345);
    socket.setSoTimeout(5000);
    socket.joinGroup(group , iface);
    byte[] b = new byte[4096];
    DatagramPacket datagram = new DatagramPacket(b, b.length);
    try {
    socket.receive(datagram);
    System.out.println("Success");
    catch (SocketTimeoutException ste) {
    System.out.println("Failure");
    socket.leaveGroup(group, iface);
    This is still not working.
    The multicast is coming from the network (not localhost), OS is Windows 7.
    When I start a multicast stream localy via VLC application on this same group and port, I receive the traffic in this Java application OK.
    Once again, Wireshark detects IGMP join and leave and multicast traffic flow on eth3 network interface initiated by the Java application, but it just doesn't see the UDP datagrams.

  • Problem with socket and object writing

    Hi,
    I programm this client/server app, the client has a point (graphic ) , the server has a point and when the mouse is moving it moves the point and the new position is send via the socket.
    The probleme is that i don't receive the good thing.
    When i display the coord of the point before sending it's good , but when receiving from the socket the coords are always the same ...
    i don't understand .
    Well , try and tell me ...
    Thx.

    oups, the program can be usefull ...
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    public class server_JFrame extends javax.swing.JFrame implements MouseListener,MouseMotionListener{
    point p1,p2;
    server s;
    public server_JFrame()
    this.setSize(600,400);
    addMouseListener(this);
    addMouseMotionListener(this);
    p2=new point(50,50,new Color(0,0,255));
    p1=new point(200,200,new Color(255,0,0));
    s = new server(p2,this);
    public void paint(Graphics g)
    super.paint(g);
    g.setColor(p1.get_color());
    g.fillOval(p1.get_x(), p1.get_y(),10,10);
    g.setColor(p2.get_color());
    g.fillOval(p2.get_x(), p2.get_y(),10,10);
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseDragged(MouseEvent e) {}
    public void mouseMoved(MouseEvent e)
    p1.set_x(e.getX());
    p1.set_y(e.getY());
    s.write_point(p1);
    repaint();
    public static void main(String args[])
         server_JFrame sjf = new server_JFrame();
    sjf.setDefaultCloseOperation(EXIT_ON_CLOSE);
         sjf.setTitle("server");
    sjf.show();
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class server {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public server(point p,Container c)
    p_=p;
    c_=c;
    try
    ServerSocket server = new java.net.ServerSocket(80);
    System.out.println("attente d'un client");
    java.net.Socket client = server.accept();
    System.out.println("client accept�");
    Istream_ = new ObjectInputStream(client.getInputStream());
    Ostream_ = new ObjectOutputStream(client.getOutputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) { exception.printStackTrace(); }
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    public class client_JFrame extends javax.swing.JFrame implements MouseListener,MouseMotionListener{
    point p1,p2;
    client c;
    public client_JFrame()
    this.setSize(600,400);
    addMouseListener(this);
    addMouseMotionListener(this);
    p1=new point(50,50,new Color(0,0,255));
    p2=new point(200,200,new Color(255,0,0));
    c = new client(p2,this);
    public void paint(Graphics g)
    super.paint(g);
    g.setColor(p1.get_color());
    g.fillOval(p1.get_x(), p1.get_y(),10,10);
    g.setColor(p2.get_color());
    g.fillOval(p2.get_x(), p2.get_y(),10,10);
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseDragged(MouseEvent e) {}
    public void mouseMoved(MouseEvent e)
    p1.set_x(e.getX());
    p1.set_y(e.getY());
    c.write_point(p1);
    repaint();
    public static void main(String args[])
         client_JFrame cjf = new client_JFrame();
    cjf.setDefaultCloseOperation(EXIT_ON_CLOSE);
         cjf.setTitle("client");
    cjf.show();
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class client {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public client(point p,Container c)
    p_=p;
    c_=c;
    try
    ipJDialog ipjd = new ipJDialog();
    String ip = ipjd.getvalue();
    Socket socket = new Socket(ip,80);
    System.out.println("connection avec serveur reussi");
    Ostream_ = new ObjectOutputStream(socket.getOutputStream());
    Istream_ = new ObjectInputStream(socket.getInputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) {*exception.printStackTrace();*/System.out.println("connection avec serveur echou�");}
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    public class client {
    point p_;
    Container c_;
    ObjectInputStream Istream_;
    ObjectOutputStream Ostream_;
    public client(point p,Container c)
    p_=p;
    c_=c;
    try
    ipJDialog ipjd = new ipJDialog();
    String ip = ipjd.getvalue();
    Socket socket = new Socket(ip,80);
    System.out.println("connection avec serveur reussi");
    Ostream_ = new ObjectOutputStream(socket.getOutputStream());
    Istream_ = new ObjectInputStream(socket.getInputStream());
    ThreadRead tr = new ThreadRead(Istream_,p_,c_);
    catch (Exception exception) {*exception.printStackTrace();*/System.out.println("connection avec serveur echou�");}
    public void write_point(point p)
    try
    System.out.print("x="+p.get_x());
    System.out.println(" y="+p.get_y());
    Ostream_.flush();
    Ostream_.writeObject(p);
    Ostream_.flush();
    catch (Exception exception) {exception.printStackTrace();}
    import java.io.Serializable;
    import java.awt.*;
    public class point implements Serializable{
    private int x_;
    private int y_;
    private Color c_;
    public point(int x, int y, Color c) {
    x_=x;
    y_=y;
    c_=c;
    public int get_x() { return x_ ; }
    public int get_y() { return y_ ; }
    public void set_x(int x) { x_=x ; }
    public void set_y(int y) { y_=y ; }
    public Color get_color() { return c_ ; }
    }

Maybe you are looking for

  • How to create a video carousel component

    Hi , I have a doubt. For images we have one component carousel. Like Carousel component ,Can we develop a component for videos and it should suppport all formats (FLV,MP4,WMV) Can u guys pls help me out. Thanks & Regards, Prasad.

  • Iphone isync iproblem

    hi, just got my iphone... all is well but it wont sync my address book, ical, bookmarks and mail. i have tried re-installing tiger but i still seem to have a problem with isync. when i tried to open it to reset the preferences and to enable sync it b

  • Can i watch us store in europe?

    I have a movie I want to see which seems to be only available in the US? Can I watch movies using that store? thanks

  • DQXI 11.7.1 High Availabilty Setup

    We are looking to setup DQXI in a high availability clustered environment. We are going to start with two servers and work our way up from there. We only need to balance out the transactional calls (not the batch's). We are planning on using an exist

  • IPhone shuts automatically off with battery over 10%

    Hi My iPhone shutted automatically off today with a battery of 12%. I only could start it again by recharging. It's the second time in two weeks that happened, the first time with iOS 5.1.1, now with iOS 6. Otherwise I don't have any problems with my