Server socket needs to sends images to applet

Dear expert programmers
I've got a simple socket server ruuning on my machine which accepts a connection from an applet on an arbitrary port.
The problem I have is that it needs to "CONSTANTLY" take screenshots of the desktop and send them to the applet so that the applet can load them for people to see. It's a remote desktop project I've been working on for some time now and I have no idea on how to create images and send them using sockets to an applet.
Could someone please help me - sample code would be appreciated - also efficiency of sending desktop scrrenshots isn't an issue for now.
Many thanks

ok, need to know what you have/can get working....
have you got any working commuincation between Applet and server?
could you write a method that converts int to 4 bytes?
and use that to convert int[] to byte[] (4 times as big)?
for the screen capture part..
Robot robber=new Robot();
BufferedImage bi=robber.createScreenCapture(new Rectangle(0,0,screenWidth,screenHeight));
int[] pixels=bi.getRGB(0,0,screenWidth,screenHeight,null,0,screenWidth);
byte[] data=toByteArray(pixels);get the outputStream from the connected Socket and use its write(byte[] b) method to send the data
at the Applet, get the InputStream, use its read(byte[] b) method to get the data
re-pack to int[] and use setRGB(0,0,screenWidth,screenHeight,int[] data,0,screenWidth)
get the Graphics Object for the display element of the Applet you want to show the image and use drawImage(BufferedImage,0,0,null) to display

Similar Messages

  • Problem in sending image from applet to servlet

    dear friends,
    i have a need to send an image from applet to servlet via HttpConnection and getting back that image from applet.
    i am struggling with this sice many hours and got tired by searching any post that would help me but haven't got yet.
    i tried using this code but it dosent make any execution sit right. i got NPE at ImageIcon.getDescription() line;
    at applet side
          jf.setContentPane(getJContentPane());
                     FileDialog fd=new FileDialog(jf,"hi");
                     fd.setMode(FileDialog.LOAD);
                     fd.setVisible(true);   
                     v=new Vector();
                     try{                                                
                               FileInputStream fis=new FileInputStream(new File(fd.getDirectory()+fd.getFile()));      
                               byte[] imgbuffer=new byte[fis.available()];
                               fis.read(imgbuffer);
                               ImageIcon imgdata=new ImageIcon(imgbuffer);
                               v.add(0,imgicon);
                                String strwp ="/UASProject/Storeimage";              
                                URL servletURL = new URL(getCodeBase(),strwp);             
                                HttpURLConnection servletCon = (HttpURLConnection)servletURL.openConnection();       
                                servletCon.setDoInput(true); 
                                servletCon.setDoOutput(true);
                                servletCon.setUseCaches(false);
                                servletCon.setDefaultUseCaches(false);   
                                servletCon.setRequestMethod("POST");     
                                servletCon.setRequestProperty("Content-Type", "application/octet-stream");   
                                servletCon.connect();            
                                ObjectOutputStream oboutStream = new ObjectOutputStream(servletCon.getOutputStream());                     
                                oboutStream.writeObject(v);
                                v.remove(0);
                                oboutStream.flush();      
                                oboutStream.close();  
                                //read back from servlet
                                ObjectInputStream inputStream = new ObjectInputStream(servletCon.getInputStream());
                                 v= (Vector)inputStream.readObject();                     
                                 imgicon=(ImageIcon)v.get(1);
                                 showimg.setIcon(imgicon);
                                 this.getContentPane().validate();
                                 this.validate();  
                                inputStream.close();                                                        
                             //  repaint();
                     }catch(Exception e){e.printStackTrace();}  and this is at servlet side
            try {       
                         Vector v=new Vector();                    
                         ObjectInputStream inputFromjsp = new ObjectInputStream(request.getInputStream());                                      
                          v = (Vector)inputFromjsp.readObject();                                                                                                          
                          imgicon=(ImageIcon)v.get(0);                     
                          inputFromjsp.close();            
                          System.out.println(imgicon.getDescription());                                      
                          v.remove(0);
                          v.add(1,imgicon);
    //sending back to applet
                           response.setContentType("application/octet-stream");
                          ObjectOutputStream oboutstream=new ObjectOutputStream(response.getOutputStream());            
                          oboutstream.writeObject(v);
                          oboutstream.flush();
                          oboutstream.close();
                   } catch (Exception e) {e.printStackTrace();}  i really need your help. please let me out of this headche
    thanks
    Edited by: san_4u on Nov 24, 2007 1:00 PM

    BalusC wrote:
    san_4u wrote:
    how can i made a HttpClient PostMethod using java applets? as i have experience making request using HttpURLConnection.POST method. ok first of all i am going make a search of this only after i will tell. please be onlineOnce again, see link [3] in my first reply of your former topic.
    yeah! i got the related topic at http://www.theserverside.com/tt/articles/article.tss?l=HttpClient_FileUpload. please look it, i am reading it right now and expecting to be reliable for me.
    well what i got, when request made by html code(stated above) then all the form fields and file data mixed as binary data and available in HttpServletRequest.getinputstream. and at servlet side we have to use a mutipart parser of DiskFileItemFactory class that automatically parse the file data and return a FileItem object cotaing the actual file data,right?.You can also setup the MultipartFilter in your environment and don't >care about it further. Uploaded files will be available as request attributes in the servlet.is the multipartfilter class file available in jar files(that u suggested to add in yours article) so that i can use it directly? one more thing the import org.apache.commons.httpclient package is not available in these jar files, so where can got it from?
    one mere question..
    i looked somewhere that when we request for a file from webserver using web browser then there is a server that process our request and after retrieving that file from database it sends back as response.
    now i confused that, wheather these webservers are like apache tomcat, IBM's webspher etc those processes these request or there is a unique server that always turned on and process all the request?
    because, suppose in an orgnisation made it's website using its own server then, in fact, all the time it will not turned on its server or yes it will? and a user can make a search for kind of information about this orgnisation at any time.
    hopes, you will have understand my quary, then please let me know the actual process
    thanks
    Edited by: san_4u on Nov 25, 2007 11:25 AM

  • Are socket needed to send emails?????

    hi guys,
    lets say i need to send an email notification everytime i finish doing a cetain task....do i need to create and use a socket to send these emails????
    thanks in advance for any help...
    lost and blur.
    Below are the codes to send email:
    (So are socket needed???)
    public void execute(String mailto, String mailcc, String mailsub, String mailbody){
    //session object inside the catch block also(in case of DCOException).
    DCOSession ds = null;
    try{
    ds = new DCOSession(); // Create new DCOSession object
    ds.login("erstest02"); // Log in as current Notes client user
    DCOMail dm = new DCOMail(); // Create new DCOMail object
    dm.setDcoSession(ds);// Pass DCOSession to mail
    //dm.setDebug(true);
    dm.setSendTo(mailto);
    dm.setCopyTo(mailcc);
    //dm.setBlindCopyTo();
    dm.setSubject(mailsub);
    dm.setBody(mailbody);
    //System.out.println("before mail sent");
    dm.send(); // Send the mail
    ds.logout(); // Log out of the session
    System.out.println("mail sent to "+mailto);
    }catch(DCOException e1){
    e1.printStackTrace();
    try{
    if(ds!=null){
    ds.logout(); //Log out of session even if exception is thrown
    }catch(Exception ee1){
    System.out.println("Exception thrown while trying to logout of session");
    ee1.printStackTrace();
    }catch(Exception e){
    e.printStackTrace();
    try{
    if(ds!=null){
    ds.logout(); //Log out of session even if exception is thrown
    }catch(Exception ee2){
    System.out.println("Exception thrown while trying to logout of session");
    ee2.printStackTrace();
    }

    lets say i need to send an email notification
    everytime i finish doing a cetain task....do i need
    to create and use a socket to send these emails????Yes, sockets are needed to send emails. However, you don't need to deal with them yourself. You can use the JavaMail API. It will hide those low level details from you and let you deal with concepts that are related to sending emails--addresses, contents, servers, etc.
    http://java.sun.com/developer/onlineTraining/JavaMail/

  • Creating server/client program to send images

    Hi, I'm trying to create a program where the server and client can send pictures to each other. I don't really know where to start. I want to try to work on the most tedious part of the program first.
    A rough image of how it would execute in the following order:
    1.User type in their username
    2.User selects if they are the server or client
    3.User types in IP address/route number (kind of fuzzy on this one)
    4.The window for transferring photo
    Thank you very much.
    (I'm new at programming, but my goal is to try to develop the program with minimum help from my friends as possible.)

    The best thing to do is to get introduced to the API that you will be using. The most difficult part will be establishing a connection to from client to server and sending/receiving data. Look at the Java API here: http://java.sun.com/javase/6/docs/api/ and scroll down the left side to the URLConnection class, which is the one you will use for the communication.
    When using URLConnection, see http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html to help get around some of the traps in using it.
    Start with two separate programs, one server and one client. Make both programs command line applications, and don't worry about users etc.. to start with. Maybe even use a fixed IP address and Port for the server. Start with sending text back and forth, and when you get that down switch to images. Then worry about the user interface, logging in, selecting images to serve, location to save to, etc...

  • TS2755 After updating to IOS 7.0.6 I can no longer send or receive text images!!! I have tried everything I could find. It is driving me crazy I need to send images for work! I am using a 4S, had NO PROBLEMS until I upgraded the software!!!!

    I have tried everything I could locate. I am using a 4S and had not a problem prior to updating the software!!! I need to text images alot due to my job. I am going crazy!!!! Any suggestions????

    SMS is a carrier feature, what did your phone carrier say when you contacted them about your issue?
    Double check you have MMS turn on in message settings.

  • Need to send a email alert to Projectmanger when publishing a project in project server 2010 PWA site

    Hi All
    When creating and publishing a project in PWA(server 2010) need to send a mail alert to the concerned project manager.
    How can i achieve this..
    I have configured the outgoing mail sending in sharepoint and its working fine now.
    Please help me..
    Thanks Advance
    SharePoint Module Lead Assyst International Private Ltd Cochin India

    Nothing is built in Project Server to do this for you automatically.
    They way I have done this in the past is to create a SQL job using SSIS.  It runs every hour and when it sees a project schedule that has a recent PUBLISHED date then this is a trigger to send an email to project manager.
    Cheers!
    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

  • Send Images from CVS-1450 to host

    How is the better way to retrieve the acquired images from CVS when I realize an host application?
    Is the VI-Server the better solution?
    Anyone has some examples?
    Thanks

    Have a look at the following example on www.ni.com :
    Compress IMAQ Images to JPEG Streams for Faster Transfer
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E88
    D56A4E034080020E74861&p_node=DZ52507&p_submitted=N&p_rank=&p_answer=&p_sourc
    e=External
    CVS side :
    You acquire the images, compress the images, then use a TCP server in order
    to send images to the host.
    Host side:
    Use a TCP client to retrieve the images.
    Jean-Christophe BENOIT
    Alliance Vision
    "FABIOSIEMENS" wrote in message
    news:[email protected]..
    > How is the better way to retrieve the acquired images from CVS when I
    > realize an host application?
    > Is the VI-Server the better solution?
    > Anyone has some exam
    ples?
    > Thanks

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Need help saving image to SQL as BLOB, then sending as email attachment

    Hi folks,
    These forums have gotten me most of the way through this particular project, but I'm finally stumped...
    First, I'll describe exactly what I'm trying to do: the user chooses an image file client side and the server-side code then converts it to binary data and saves it to SQL. Then as a separate step, an email will be sent out with that image file loaded from the DB as an attachment.
    So I've actually got most of this working. I'm using the O'Reilly MultipartParser class to pull the file input stream from the Request and insert it into SQL BLOB column ("image" datatype). I can successfully send Text attachments by simply converting the binary data back to a string and then using a subclass of DataSource (ByteArrayDataSource) to feed it to the mail object.
    After getting the text documents to work, I then moved on to trying to send images.
    I tried to send images using essentially the same technique as sending text. The image file gets saved to SQL the same way and I then convert the binary data back to a string an attach it. The only difference is that I set the content-type to "image/gif".
    I didn't really expect this to work, however, I am able to "Preview" very simple Gifs (in XP) that I've attached. I cannot "Open" them, though, and I cannot even "Preview" more complicated Gifs.
    So on to my real questions. I didn't really expect that you could simply output binary image data into Text format and simply slap on a ".gif" and expect it to work. Am I right about that? XP's "preview" option seems to read it okay, but I really need to be able to "open" these files.
    So basically I need to know what to DO with that binary data in SQL in order to successfully attach it as a true image file. Is this an encoding issue? MIME type?
    I didn't want to paste all the code but I'll paste the snippet that deals with the attachment section. If you'd like to see any other parts, please just let me know...
    MyBlobObject v_blob = new MyBlobObject(m_cp);  // the getBlobStr() method of this object simply grabs the data from SQL as a String
    DataSource source = new ByteArrayDataSource(v_blob.getBlobStr(),"application/octet-stream");
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setHeader("content-type","image/gif");
    messageBodyPart.setFileName(v_fileName);
    ...Another interesting thing I'm seeing is that when I view the small Gif as text, I see this:
    GIF89a � !� , D ;
    While the file I'm getting from SQL as an attachment looks like this:
    GIF89a ? !? , D ;
    Obviously, the question marks are unknown, but I'm not quite sure why. I outputted the char values as integers and found that the first question mark is 65408 and the second one's value is 65529. Obviously something is getting changed somewhere in the process, but I'm not quite sure how and where.
    anyway, thanks in advance for any advice!

    Nevermind! Of course, I figured it all out after writing that long post.
    I had tried using a byte array instead of the String in the ByteArrayDataSource and it hadn't worked. However once I cleaned up the code a bit I got it working.
    This links has it all...
    http://www.magelang.com/faq/view.jsp?EID=498439
    thanks anyway!

  • J2me send image using php as server

    hii all,can you help me give me a souce code for send image in j2me to server(i'm using php)????????? cause i need for my final projects
    thanks

    The reason i want to use gmail because i can't use smtp university's mail server( looking to the apple server error log is say something about IsSMTP(); function. today, i had discussion with them(ICT dept) and they can't solve it as there's no apple server used before/now and no one familiar with it. they give me other alternative by using a "secret server", a subdomain name were given with no smtp authentication. no username or password were used, not even using any ssl or tsl security. they give me this last solution when i install joomla on the other windows server and try to use university smtp server with email account. error saying cannot connect to smtp server. i did try also using joomla on my apple server still with the error. so what i understand now is that its related to university global networking security/policy setting(correct me if i'm wrong). so for the SL server, its should be super easy to setup if you are yourself configuring the internet direct to your ISP. thanks very much to Camelt for quick answered. So i should not facing any problem with apple server if i bought and connect it direct to my ISP, right Camelot?

  • Need to send a mail from a specific From mail ID thorgh specific Mail serve

    Hi,
    If any errors occured in my interface validation program(plsql) I need to send mail to some mail ids,
    But I need to use specific from mail id and mail server.
    I have no idea of Shell scripting, I tried it with plsql itself but not worked. My Application server is different from DB server.
    Please let me know if any one has the code or any thoughts.
    Thanks

    Please see these links.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=UTL_SMTP&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Send+AND+email+AND+PL%2FSQL&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Email+AND+PL%2FSQL&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

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

  • If i need 2 send an Object that allready exist like Image .....

    Hi Folks ,
    i need an Advise to my problems.
    My problems is like that
    I need 2 send an Object a lot of times throw the Soket
    for this i need packing my Objects and send them 1 after 1
    i will try say more clearly i need 2 send a lot of Frames (Image Capture)
    Like a Movie but not Movie ;P
    This Images Captures of my screen(like printscreen)
    is an Object of BufferImage bi
    i have a lot Objects of BufferImage bcuz alws my screen changing every move i do with mouse and enter 2 new folder i get new printscreen
    i capture it so that i need Send throw the soket a lot of Objects
    from BufferImage and as u know Guys
    BufferImage is Java Class
    import java.awt.image.BufferedImage;
    so my questionsis :
    1) What is the best way 2 send a lot of BufferImage Objects ?
    2) i need use Serialization for that ( this is the short way and remember i want send Objects not Files)?
    3) Shold i i save every imageCapture 2 File and send the file?
    Then i will need 2 send a lot of Files or 1 File that alws i will change and he will contin the Newest Screen Capture?
    4) from all my qestions what is the Best way?( Best way i guss is the faster way to send the CaptureImage)
    5) how can i send BufferImage Object with Serialization?
    humm i guss i write 2 much question will be nice if some 1 will give any Advise or somthing that can Help .
    tnx

    BufferedImage is not serializable so you cant serialize it directly.
    But however you can make it serializable by creatigna sub class of it which implements Serializable interface and you should also implement a custom serialization logic for that new class.
    But also remember sending image as represented in java will be quite expensive since it is a uncompressed bitmap. Best approach will be using image IO to send images in JPEG (or PNG for loss less compression) format. You can construct image objects at the other end.
    You dont have to store images in to files you can store them in to variables (byte arrays) before sending.
    Some time I did something similer and there I also implemented something like this. Before sending the captured image date through the wire I compaired it with the previously send image (Using CRC) and I send the latest image only if it has a different checksum from the last sent. That way I avoided sending multiple images when the screen is not changing.

  • Need software which can send images to my editor, have them make selections, share them with me so I can edit the images and send the final results back to them.  Will Lightroom work?

    Need software which can send images to my editor, have them make selections, share them with me so I can edit the images and send the final results back to them.  Will Lightroom work?

    What I would like to do is to use Lightroom as I have been doing with LR 5.7.  Tag certain images to be shared to the Creative Cloud which my editor can then see and tag as to which she would like to see final versions of.  In the best case, I would then see these tags and edit the images as appropriate and save the JPEGs back to the Cloud where she can download them for final production.
    Possible?

  • How can I control the image size when I export form iphoto, the choice is too limited, I need to send a photo under 3 MB but if I choose high quaulity it is only 1.1 and i need to keep the best quaulity I can. Thanks for help.

    How can I control the image size when I export form iphoto, the choice is too limited, I need to send a photo under 3 MB but if I choose high quaulity it is only 1.1 and i need to keep the best quaulity I can. Thanks for help.

    Any image can only be as large as the Original. With a program like Photoshop you can UpRes an image and get it to a bigger size, larger files size as well, but the actual quality of the image will be degraded, depending on the UpRes system and the original quality of the image.
    iPhoto is not the program to be doing that in and I don't think it even has that option.
    So I suspect the image you are trying to send isn't much bigger than what you are getting. You can also try Exporting it from iPhoto to yopur desktop and see what size you end up with. If it is still that 209KB +/- file size then that is the size of the original image.

Maybe you are looking for