Printing through socket programming

Hi,
i have written a clent side socket program which connects to my printer.
and print the byte[] input stream . I ran my prog and it didn't throw any exception/error. The connection was also made successfully however no page is being printed by the printer.
Any suggestion over this issue?
Code:-      public static void testPrint(byte[] b, InetAddress printerName, int port) throws IOException{          
          System.out.println("Inside Test method");
          System.out.println("PrinterName is" +printerName +"---"+"port is" +port +"----byte is " +b.toString());
          if (b!= null) {
               Socket so = null;
               OutputStream out = null;
               try {
                    so = new Socket(printerName,port);               
                if (!so.isConnected()) {
                   System.out.println(printerName + ": " + port + "Connect failed");
                out = so.getOutputStream();                    
                    if(out != null) {
                         System.out.println("OutPut Stream is not null"+out);
                         out.write(b);
                         out.flush();
                    else {
                         System.out.println("OutPut Stream is null");
               catch (UnknownHostException ue) {
                    System.out.println("Printer is not recognised" +ue);               
               catch (IOException ioe) {
                    System.out.println("I/O error" +ioe);
               finally {
                    try {
                         if (out != null) {                              
                              out.close();
                    catch (IOException ioe) {
                         System.out.println("Unable to close output stream for connection : " + printerName + " : " + port);
                    try {
                         if (so != null) {
                              System.out.println("Closing Socket Connection");
                              so.close();
                    catch (IOException ioe) {
                         System.out.println("Unable to close socket connection : " + printerName + " : " + port);
          }

Hi,
i have written a clent side socket program which connects to my printer.
and print the byte[] input stream . I ran my prog and it didn't throw any exception/error. The connection was also made successfully however no page is being printed by the printer.
Any suggestion over this issue?
Code:-      public static void testPrint(byte[] b, InetAddress printerName, int port) throws IOException{          
          System.out.println("Inside Test method");
          System.out.println("PrinterName is" +printerName +"---"+"port is" +port +"----byte is " +b.toString());
          if (b!= null) {
               Socket so = null;
               OutputStream out = null;
               try {
                    so = new Socket(printerName,port);               
                if (!so.isConnected()) {
                   System.out.println(printerName + ": " + port + "Connect failed");
                out = so.getOutputStream();                    
                    if(out != null) {
                         System.out.println("OutPut Stream is not null"+out);
                         out.write(b);
                         out.flush();
                    else {
                         System.out.println("OutPut Stream is null");
               catch (UnknownHostException ue) {
                    System.out.println("Printer is not recognised" +ue);               
               catch (IOException ioe) {
                    System.out.println("I/O error" +ioe);
               finally {
                    try {
                         if (out != null) {                              
                              out.close();
                    catch (IOException ioe) {
                         System.out.println("Unable to close output stream for connection : " + printerName + " : " + port);
                    try {
                         if (so != null) {
                              System.out.println("Closing Socket Connection");
                              so.close();
                    catch (IOException ioe) {
                         System.out.println("Unable to close socket connection : " + printerName + " : " + port);
          }

Similar Messages

  • Transfering a file through Socket programming

    Hi all,
    I want to return a file from server to client through a socket. I tried using ObjectOutput Stream where in I returned a java.io.File from server. But at client side when I say file.getLeangth() it comes as 0 and if I try to assign FileInputStream on the object it throws an exception as the file not found as the path associated with the file will be of Server.
    So can anyone help as to how to transfer a file through socket programming???
    thx in advance
    MK

    java.io.File is NOT the contents of the file. It really just represents the path.
    If you want to transfer the file's contents, you'll have to use a FileInputStream or FileReader, read from it, and then write the bytes or chars on the wire.

  • Unable to print through Java program

    Hi all,
    I have downloaded a sample java code to print text. When i try to print on solaris, it displays some postscript characters like:
    %! PS-Adobe-3.0%%BeginProlog/imStr 0 def /heximageSrc....
    But i am able to print the same information through lp command correctly.
    I am using EPSON - LP8200. As per my knowledge, this printer doesn't support postscript printing
    The sample java code works perfectly on Win2k connected to the same printer.
    Please help me out. I am stuckup in this problem for quite a few days
    Below is the code that i am using
    // This example is from the book Java AWT Reference by John Zukowski.
    // Written by John Zukowski. Copyright (c) 1997 O'Reilly & Associates.
    // You may study, use, modify, and distribute this example for any purpose.
    // This example is provided WITHOUT WARRANTY either expressed or
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.awt.print.*;
    public class TestPrintEx extends Frame implements Printable {
    TextArea textArea;
    Label statusInfo;
    Button loadButton, printButton, closeButton;
    Properties p = new Properties();
    Vector pages = new Vector();
    static boolean bFirstTime = false;
    public TestPrintEx() {
    super ("File Loader");
    add (statusInfo = new Label(), "North");
    Panel p = new Panel ();
    p.add (loadButton = new Button ("Load"));
    loadButton.addActionListener( new LoadFileCommand() );
    p.add (printButton = new Button ("Print"));
    printButton.addActionListener( new PrintCommand() );
    p.add (closeButton = new Button ("Close"));
    closeButton.addActionListener( new CloseCommand() );
    add (p, "South");
    add (textArea = new TextArea (10, 40), "Center");
    pack();
    public static void main (String args[]) {
    TestPrintEx f = new TestPrintEx();
    f.show();
    // Bail Out
    class CloseCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    System.exit (0);
    // Load a file into the text area.
    class LoadFileCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
    int state;
    String msg;
    FileDialog file = new FileDialog (TestPrintEx.this, "Load File", FileDialog.LOAD);
    file.setFile ("*.java"); // Set initial filename filter
    file.show(); // Blocks
    String curFile;
    if ((curFile = file.getFile()) != null) {
    String filename = file.getDirectory() + curFile;
    char[] data;
    setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    File f = new File (filename);
    try {
    FileReader fin = new FileReader (f);
    int filesize = (int)f.length();
    data = new char[filesize];
    fin.read (data, 0, filesize);
    } catch (FileNotFoundException exc) {
    String errorString = "File Not Found: " + filename;
    data = errorString.toCharArray ();
    } catch (IOException exc) {
    String errorString = "IOException: " + filename;
    data = errorString.toCharArray ();
    statusInfo.setText ("Load: " + filename);
    textArea.setText (new String (data));
         System.out.println("#### " + new String(data));
    setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    // Print a file into the text area.
    class PrintCommand implements ActionListener {
    public void actionPerformed (ActionEvent e) {
         PrinterJob pjob = PrinterJob.getPrinterJob();
         TestPrintEx.bFirstTime = true;
         pjob.setPrintable(TestPrintEx.this);
         try{
         //pjob.print();
         pjob.printDialog();
         catch(PrinterException pe)
              pe.printStackTrace();
         pjob.printDialog();
    class Page
         Vector lines;
         Page()
              lines = new Vector();
         void addLine(String s)
              lines.addElement(s);
         Enumeration getLines()
              return lines.elements();
         void print(Graphics pg, PageFormat pf)
              System.out.println("Printing page now");
              // Note: String is immutable so won't change while printing.
              if (!(pg instanceof PrinterGraphics)) {
              throw new IllegalArgumentException ("Graphics context not PrintGraphics");
              //--- Create the Graphics2D object
              Graphics2D g2d = (Graphics2D) pg;
              //--- Translate the origin to 0,0 for the top left corner
              g2d.translate (pf.getImageableX (), pf.getImageableY ());
              //--- Set the default drawing color to black
              g2d.setPaint (Color.black);
              //--- Draw a border around the page
              Rectangle border = new Rectangle(0,
                             0,
                             (int)(pf.getImageableWidth()),
                             (int)(pf.getImageableHeight()));
              g2d.draw (border);
              int pageHeight = (int)pf.getImageableHeight();
              //Font helv = new Font("Helvetica", Font.PLAIN, 12);
              Font helv = new Font(null, Font.PLAIN, 12);
              //have to set the font to get any output
              g2d.setFont (helv);
              FontMetrics fm = g2d.getFontMetrics(helv);
              int fontHeight = fm.getHeight();
              int fontDescent = fm.getDescent();
              int curHeight = (int)(pf.getImageableY() + 72);
              int size = lines.size();
         for(int i = 0; i < size; i++)
              curHeight += fontHeight;
              if (g2d != null) {
                   g2d.drawString ((String)lines.elementAt(i),
                        (int)(pf.getImageableX () + 72), curHeight - fontDescent);
              } else {
                   System.out.println ("pg null");
              g2d.dispose();
    public int print(Graphics pg, PageFormat pf, int index)
         if(bFirstTime)
              System.out.println("First time - paginating");
              paginate(pg, pf);
              bFirstTime = false;
         System.out.println("No of pages = " + pages.size());
         if(!isValidIndex(index))
              return Printable.NO_SUCH_PAGE;
         ((Page)pages.elementAt(index)).print(pg, pf);
         return Printable.PAGE_EXISTS;
    boolean isValidIndex(int index)
         if(index >= 0 && index < pages.size())
              return true;
         return false;
    void paginate(Graphics pg, PageFormat pf)
         pages.clear();
    // Note: String is immutable so won't change while printing.
    if (!(pg instanceof PrinterGraphics)) {
    throw new IllegalArgumentException ("Graphics context not PrintGraphics");
         //--- Create the Graphics2D object
         Graphics2D g2d = (Graphics2D) pg;
         //--- Translate the origin to 0,0 for the top left corner
         g2d.translate (pf.getImageableX (), pf.getImageableY ());
         String s = textArea.getText();
    StringReader sr = new StringReader (s);
    LineNumberReader lnr = new LineNumberReader (sr);
    String nextLine;
         int pageHeight = (int)pf.getImageableHeight();
    Font helv = new Font(null, Font.PLAIN, 12);
    //have to set the font to get any output
    g2d.setFont (helv);
    FontMetrics fm = g2d.getFontMetrics(helv);
    int fontHeight = fm.getHeight();
    int fontDescent = fm.getDescent();
    int curHeight = (int)(pf.getImageableY() + 72);
         Page page = new Page();
         pages.addElement(page);
    try {
    do {
    nextLine = lnr.readLine();
    if (nextLine != null) {
    if ((curHeight + fontHeight) > pageHeight - 72) {
                   page = new Page();
    pages.addElement(page);
    curHeight = 0;
    curHeight += fontHeight;
    if (g2d != null) {
                   page.addLine(nextLine);
    } else {
    System.out.println ("pg null");
    } while (nextLine != null);
    } catch (EOFException eof) {
    // Fine, ignore
    } catch (Throwable t) { // Anything else
    t.printStackTrace();
    Thanks

    Did you ever find a resolution to this problem.
    I am having the same exact problem?

  • Open Multiple Port through Socket Programming

    Hi,
    Actually I want to connect to three diff. ports on a Server from clinet, the port should be identified by a particular number.... and multiple users can access the server a the same time.... how do I program it....
    I need to program Client side....
    Thanks
    Sharad

    The client will need to be multithreaded if you want to connect to more then one port at a time from the client.
    public class Client {
    int port;
    String addr;
    ... openConnection(addr,port);
    the openConnection(String, int) method will actaully need to open a new thread where all the actual code goes. This will allow the Client class to call openConnection() again and use a new server/port. And you can keep calling this until you don't have any more local ports to bind to, or the server runs out of ports, or both.
    The book Core Java 2, volumes 1 and 2 have good examples of this and I also suggest Java Network Programming and Distributed Computing.

  • Tansfer files through socket

    Hi all
    Can anyone tell me that how can i send files from server to the client through socket programming.
    if u recommend to send file using
    int read(byte[] b, int offset, int blength)
    void write( byte[] b, int offset, int blength) then how plz tell me how can use these methods to send a receive files??? if u give a small example code then i will very greatful to u.
    Usman

    Thanks for ur help.
    but i have got it. i have designed a client and server. Client requests the server to send a specif file (Client takes the path of file from user). And server sends the file to the client.
    I have checked this program on many files. like *.exe, *.txt, *.dat, *.zip, *.mp3, *.jpg.
    it worked smoothly. I have test to trasfer a file of 700MB and it worked correctly.
    Ooops! i did not check it on Network. i run these program on my own computer. both client and server were running on same computer.
    but i am facing a little problem. that is: the speed of trasfering the files is very slow.
    any1 know how to increase the speed of data transfer over the sockets ???
    And plz tell me how can i trasfer a complete directory just as i trasfered file over the sockets. (Remember: a dircetory may or may not contains may other files and also other directories
    thanks in advance...!!!
    here is the code:
    *          CLIENT            *
    import java.net.*;
    import java.io.*;
    public class TransferClient
        public static void main(String[] args)
            try
                 int fileSize = 0;
                 int readBytes = 0;     
                 final int BUFFER_SIZE = 512;
                 byte[] buffer = new byte[BUFFER_SIZE];       
                   Socket sockClient = new Socket(InetAddress.getLocalHost(),2000);     
                   DataInputStream dataInputStream = new DataInputStream(sockClient.getInputStream());
                   BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream("filename.ext"));
                   BufferedReader inputUser   = new BufferedReader(new InputStreamReader(System.in)); //For User input
                   PrintWriter output = new PrintWriter (sockClient.getOutputStream(), true);     //To send the user input to the server
                   //get path from user
                   System.out.print("Enter the complete path of file: ");
                   String path = inputUser.readLine();
                   //send path to server
                   output.println(path);
                   readBytes = dataInputStream.readInt();
                   while(readBytes > 0)
                        readBytes = dataInputStream.read(buffer, 0, readBytes);
                        fileSize = fileSize + readBytes;
                        bufferedOutputStream.write(buffer, 0, readBytes);
                        readBytes = dataInputStream.readInt();
                   }//end while
                   bufferedOutputStream.flush();
                   System.out.println("Received Bytes:  " + fileSize);
                   dataInputStream.close();
                   bufferedOutputStream.close();                              
                   inputUser.close();
                   output.close();
                   sockClient.close();
            }//end try
            catch(IOException ioException)
                 ioException.printStackTrace();
            }//end catch
        }//end main()
    }//end class TransferClient
    *          SERVER            *
    import java.io.*;
    import java.net.*;
    public class TransferServer
        public static void main(String[] args)
             int fileSize = 0;         
             int readBytes = 0;
             final int BUFFER_SIZE = 512;
             byte[] buffer = new byte[BUFFER_SIZE];
             try
                  ServerSocket ss = new ServerSocket(2000);
                  System.out.println("Server Strarts...");
                  Socket sock = ss.accept();
                  BufferedReader clientInput = new BufferedReader(new InputStreamReader (sock.getInputStream()));
                   DataOutputStream dataOutputStream = new DataOutputStream(sock.getOutputStream());
                   PrintWriter output = new PrintWriter(sock.getOutputStream(), true);
                   System.out.println ("Connection Received");          
                   String path = clientInput.readLine();               
                   File f = new File(path);                    
                   if( f.exists() )
                        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(path));               
                        while((readBytes = bufferedInputStream.read(buffer))!= -1)
                             fileSize = fileSize + readBytes;
                             dataOutputStream.writeInt(readBytes);
                             dataOutputStream.write(buffer, 0, readBytes); 
                        }//end while
                        dataOutputStream.writeInt(0);          
                        System.out.println("Sent Bytes:  " + fileSize);
                        bufferedInputStream.close();
                   }//end if
                   clientInput.close();
                   dataOutputStream.close();
             }//end try
             //catch(FileNotFoundException fileNotFoundException)
             //     output.println("Sorry! file does not exist.");
             catch(IOException ioException)
                  ioException.printStackTrace();
             }//end catch       
        }//end main()
    }//end class TransferServer

  • I contacted what I thought was Brother Support for my new printer, then I got skeptical.  He gained access through a program called TeamViewer, is my Mac safe?

    i contacted what I thought was Brother Support for my new printer, then I got skeptical.  He gained access through a program called TeamViewer, is my Mac safe?

    They're probably just interested in getting $ from you, there are several companies who advertise in a way that suggests 'official' support for all sorts of things. Unfortunately, if they had access as you describe, they potentially could have installed other software and/or read any of your files.
    Ideally - change all passwords for email/banking/login & restore a backup from before this happened.

  • Problem: Socket connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time

    Problem: Socket
    connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time
    Environment: -
    OS:
    Windows XP SP2/7
    Code:
    VC 6.0
    Dll: MFC
    Problem Description: -
    We have written a utility program which create socket (Using windows standard method [MFC]), and then make connection with another service (List Display) running
    on port 3334 in different machine and retrieve the required list data. This program was working fine in almost all the machines.
    But, we have received a severe intermittent issue on two machines. Client is facing issue in displaying the list data from port 3334.
    Attempt: -
    First we tried to debug code, and we come to know that socket is not creating in utility program. So we tried to telnet on ListDisplay service port 3334 and we were surprised that we were able to telnet, then we opened some more
    telnet window on same port 3334 around (6 to 8) window, and each cmd connected properly. But we were not able to create socket from utility program.
    Problem is severe because issue is intermittent.
    We have tried all the way, but we are not able to figure it out, that what can be the exact problem and what are the conditions, when utility program will not
    connect with ListDisplay service on port 3334.
    Kindly assist to resolve this issue. For any help, we would be really thankful.

    Hi,
    According to your description, it seems that you have created an utility program which is making connection with another service port 3334, however, two clients are facing issue in display the data list from port 3334.
    Port: 3334/TCP
    3334/TCP - Known port assignments (1 record found)
    Service
    Details
    Source
    directv-web
    Direct TV Webcasting
    IANA
    Since the port 3334 is used by directv-web service, I'd like to suggest check this service it is working well on the problematic clients.
    1. The client can be resolved in DNS well? Please run "nslookup" in the prompt command.
    2. Is there any 3rd party application interrupting? Do test in clean boot.
    2. Strongly suggest you run process monitor tool to analysis it.
    I am looking forward to your reply if you have any updated on your side.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • TCP/IP socket programming in ABAP

    Hi,
    Is there any method of TCP socket programming in ABAP? For example is there any function module for creating a socket for a IP address and port number. After that, is it possible to send binary/text data to a connected IP/port destination. I need such a solution because I need to send raw data (native commans) to barcode printer on our network which has a static IP address and listens incoming data through a fixed port number specified in its documentation. For a solution, I coded some .NET VB and built a small application that acts as a RFC server program which can be called by SAP according to definitions I made in SM59 (I defined a new TCP connection and it works well sometimes!). In this application, data coming from SAP are transferred to the barcode printer. This is achived by the .NET Socket class library. This solution works well but after a few subsequent call from SAP, connection hangs! SAP cannot call the application anymore, I test the connection in SM59 and it also hangs, so I need to restart the VB application, but this is unacceptable in our project.
    As a result, I decided to code the program that will send data to the printer in ABAP as a function module or subroutine pool, so is there any way to create a socket in ABAP and connect to specific IP/port destination? I searched for possible function modules in SE37 and possible classes in SE24 but unfortunately I could not find one. For example, do know any kind of system function in ABAP (native commands executed by CALL statement), that can be used for this purpose?
    I would appreciate any help,
    Kind regards,
    Tolga
    Edited by: Tolga Togan Duz on Dec 17, 2007 11:49 PM

    Hi,
    I doubt that there is a low level API for sockets in ABAP. There is API for HTTP but probably that won't help you. As a workaround you can use external OS commands (transactions SM69 and SM49). For example on Unix you can use netcat to transfer file. Your FM needs to dump data into folder and then call netcat to transfer file.
    Cheers

  • Can't print through Time Capsule using Windows-operating computers

    I've just bought a time capsule 500GB and it's working fine. It backups my macbook every hour and I can easily print whatever file I want through my Canon iP1800 series, which is connect to WAN port of my time capsule.
    However, I have others 2 notebooks running windows, and I can't print from them wirelessly. I've installed the airport utility and Bonjour in both computers using the CD that came with my time capsule and I followed these instructions of an old topic here (_but it didn't work out_):
    “1. Make sure the printer is recognized by the base station.
    2. Select 'Add a new printer' in Windows
    3. Select 'Local Printer' in the dialog box (auto detect and install
    should be off), click next.
    4. Choose 'Create a new port' and "Standard TCP/IP Port'. Click next.
    5. For the printer IP address, enter the address of the base station 10.0.1.1. The port name will be filled automatically. Click next.
    6. For the device type, choose 'Hewlet Packard Jet Direct', then click Finish.
    Choose your printer from the list and follow the rest of the prompts to install and configure the driver.”
    Do someone have any idea to tell me what's happening? How can I fix this problem and have Mac and Windows laptops printing through my time capsule?
    Thanks

    When you installed bonjour did the Bonjour Print Wizard appear on your desktop? Or in the program menu?
    http://support.apple.com/kb/HT3052?viewlocale=en_US
    In my personal experience Bonjour sometimes doesn't install properly and doesn't appear on either the desktop or program menu, particularly if it is installed at the same time as another piece of apple software. Each of the times this happened I removed bonjour, using Windows Setup:Add/Remove programs, and then downloaded it again individually.
    If you have the same experience as me you'll then be asked if you want to install a shortcut to the printer wizard. The wizard has done the trick for me. I've not yet had to resort to the rather more complicated "add new printer" route.
    Message was edited by: puzzlebobble

  • We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader.

    We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader.
    For which, We created and execute the below command line to call Adobe Reader and print the PDF on a printer.
    "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /T "\\<Application Server>\Report\<TEST.PDF>" "<Printer Name>".
    Current Situation: The above command line parameter when executed is working as expected in a User's Workspace.
    When executed in a command line on the Application Server, it is working as expected.
    But, the same is not working while executing it from Deployed environment.
    Software being used: 1. Adobe 11.0 enterprise version. 2. Webshpere Application Server 8.5.5.2.
    Please let us know if there is a way to enable trace logs in Adobe Reader to further diagnose this issue.

    This is the Acrobat.com forum.  Your question will have a much better chance being addressed in the Acrobat SDK forum.

  • We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader. For which, We created and execute the below command line to call Adobe Reader and print the PDF on a

    We are trying to implement a process so that any document that needs to be printed through our Java application will be printed as PDF using Adobe Reader. For which, We created and execute the below command line to call Adobe Reader and print the PDF on a printer."C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /T "\\<Application Server>\Report\<TEST.PDF>" "<Printer Name>". Current Situation: The above command line parameter when executed is working as expected in a User's Workspace. When executed in a command line on the Application Server is working as expected. But, the same is not working while executing it from Deployed environment.Software being used: 1. Adobe 11.0 enterprise version. 2. Webshpere Application Server 8.5.5.2. Please let us know if there is a way to enable trace logs in Adobe Reader to further diagnose this issue.

    This is the Acrobat.com forum.  Your question will have a much better chance being addressed in the Acrobat SDK forum.

  • How to send sms through java program?

    hi,
    i am trying to send sms through java program.i am usining ubuntu 6.04.i am using modem MC35i.i use the jSMSEnjine.jar and rxtxcomm.jar.
    these are the following program.
    import org.jsmsengine.*;
    import java.util.*;
    class SendMessage
         public static void main(String[] args)
              int status;
              // Create jSMSEngine service.
         CService srv = new CService("Com2",9600);
              //CService srv = new CService("COM2",9600);
              System.out.println();
              System.out.println("SendMessage(): sample application.");
              System.out.println(" Using " + srv._name + " " + srv._version);
              System.out.println();
              try
                   //     Initialize service.     
                   srv.initialize();
                   Thread thread =Thread.currentThread();
                   thread.sleep(1000);
                   System.out.println(srv);
                   //     Set the cache directory.
                   srv.setCacheDir(".\\");
                   //     Set the phonebook.
                   //     srv.setPhoneBook("../misc/phonebook.xml");
                   //     Connect to GSM device.
                   status = srv.connect();
                   //     Did we connect ok?
                   int st=CService.ERR_OK;
                   System.out.println(st);
                   System.out.println(status);
                   if (status == CService.ERR_OK)
                        //     Set the operation mode to PDU - default is ASCII.
                        srv.setOperationMode(CService.MODE_PDU);
                        // Set the SMSC number (set to default).
                        srv.setSmscNumber("");
                        //     Print out GSM device info...
                        System.out.println("Mobile Device Information: ");
                        System.out.println("     Manufacturer : " + srv.getDeviceInfo().getManufacturer());
                        System.out.println("     Model : " + srv.getDeviceInfo().getModel());
                        System.out.println("     Serial No : " + srv.getDeviceInfo().getSerialNo());
                        System.out.println("     IMSI : " + srv.getDeviceInfo().getImsi());
                        System.out.println("     S/W Version : " + srv.getDeviceInfo().getSwVersion());
                        System.out.println("     Battery Level : " + srv.getDeviceInfo().getBatteryLevel() + "%");
                        System.out.println("     Signal Level : " + srv.getDeviceInfo().getSignalLevel() + "%");
                        //     Create a COutgoingMessage object and dispatch it.
                        //     *** Please update the phone number with one of your choice ***
    // String smsLengthTest="Hi"+"\nTesting is going on.Test for sending unlimited number of charecter.So you will get N number of SMS.Initially I trancate the whole string by 70 charecter.Later I will put it upto 90 charecter.Some chararecter should kept for header portion.I don't know the total number.It is just test.If you got the sms u should appreciate me...This is Ripon...I have written sms program";
    String smsLengthTest="Hi\n"+"This is Govindo";
    int mao=smsLengthTest.length();
    System.out.println("Length of sms :"+mao);
    String smsNo="9433314095";
    smsNo="+91"+smsNo;
    if(mao<70)
    COutgoingMessage msg = new COutgoingMessage(smsNo,smsLengthTest);
    //     Character set is 7bit by default - lets make it UNICODE :)
    //     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
    //          this does not make ANY difference...
    msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
    if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
    else System.out.println("Message Failed!");
    else
    // COutgoingMessage msg = new COutgoingMessage(smsNo,smsLengthTest);
    // LinkedList messageList;
    // messageList = new LinkedList();
    // messageList.add(msg);
    // LinkedList maooo=new LinkedList();
    // maooo=srv.splitLargeMessages(messageList);
    int sizelength=0;
    int counter=0;
    sizelength=smsLengthTest.length();
    System.out.println("SMS length :"+sizelength);
    int smsCntr=sizelength/70;
    System.out.println("smsCntr :"+smsCntr);
    counter=smsCntr+1;
    int j=70;
    int k=0;
    try
    for(int i=0;i<smsCntr;i++)
    String test="";
    test=test+i;
    test=smsLengthTest.substring(k,j);
    System.out.println(test);
    System.out.println(test.length());
    COutgoingMessage msg = new COutgoingMessage(smsNo, test);
    System.out.println("hi this is suman" + smsNo);
    //     Character set is 7bit by default - lets make it UNICODE :)
    //     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
    //          this does not make ANY difference...
    msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
    if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
    else System.out.println("Message Failed!");
    k=k+70;
    j=j+70;
    catch(Exception e)
    System.out.println("Error...1");
    e.printStackTrace();
    e.getMessage();
    String lastPortion=smsLengthTest.substring(k);
    System.out.println(lastPortion);
    COutgoingMessage msg = new COutgoingMessage(smsNo, lastPortion);
    //     Character set is 7bit by default - lets make it UNICODE :)
    //     We can do this, because we are in PDU mode (look at line 63). When in ASCII mode,
    //          this does not make ANY difference...
    msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE);
    if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!");
    else System.out.println("Message Failed!");
                        // Disconnect from GSM device.
                        srv.disconnect();
                   else System.out.println("Connection to mobile failed, error: " + status);
              catch (Exception e)
                   e.printStackTrace();
              System.exit(0);
    the error is:
    SendMessage(): sample application.
    Using jSMSEngine API 1.2.6 (B1)
    org.jsmsengine.CService@addbf1
    0
    -101
    Connection to mobile failed, error: -101
    please help me,its very urgent.

    come back in about 5 years, we may have time for you by then.
    In the meantime, how about contacting the people who wrote that library and asking them nicely for help (rather than trying to order people to drop whatever they're doing and jump through hoops to accommodate your every wish as you're doing here)?

  • AR Invoice Printing Blank page when printed through printer

    Hi,
    I customized AR invoice to give PDF output through BI Publisher.There is no issue when tried to view the output.
    When tried to print the output through printer, It's given blank page.
    All other BI publisher reports which will give PDF output in Straight single request are printing through printer correctly.
    But AR invoice By standard program itself when fired, First a Multi Language Function will fire which will have output of 0 bytes and after that as a child request Original program with Required output will fire.
    It seems that printer is printing Parent request output.
    Can anyone please help me regarding this.
    Thanks in advance,
    Best Regards,
    Mahesh

    Hi,
    I'm guessing the concurrent program is outputting text (character mode) as opposed to PDF?
    This could be a number of reasons:
    1. Printer driver issue, e.g. the number of lines printed on the page is more than is defined for the printer driver: Try reducing the "Rows" on the current program definition
    2. Printer PRT issue, extra page break could be being inserted.
    3. The "box" in the report definition containing the address could be being expanding due to the extra address line, but not enough space so it forces a new page to be printed.
    Gareth
    Blog: http://garethroberts.blogspot.com
    Web: http://www.virtuate.com

  • How to get the form printed through the transaction ME42

    hi,
    How to get the form printed through the transaction ME42.
    For example :
    In t.code vf03 . In the main menu there is an option billing document , when we click on that we get a drop down menu which shows issue output to. If a print program call has the code to get the value from the t.code , immdiately when we click issue output to it call the form.

    Here go to ME42 put in your RFC no, in the menu Header -- Messages, go there and see if a message has been inserted, else you can insert one.
    when you save this, it will call the form.
    Regards,
    Ravi

  • Logging through sockets

    Hi
    I'm trying to send logging information through sockets using log4j.
    My configuration file is :
    log4j.rootLogger=Debug, Socket
    log4j.appender.Socket=org.apache.log4j.net.SocketAppender
    log4j.appender.Socket.Port=12345
    log4j.appender.Socket.RemoteHost=localhost
    log4j.appender.Socket.LocationInfo=true
    the server only reads the input string that the logger sends.
    I'm getting this exception on the client side:
    log4j:WARN Detected problem with connection: java.net.SocketException: Software caused connection abort: socket write error
    and this message on the server:
    Server started...
    Client accepted
    ������������org.apache.log4j.spi.LoggingEven�������������

    Ryan,
    I think if I could log to something common like Microsoft Access it would be a help to me in managing database backups and other things, as Citadel is somewhat unique in its format and methods using the Measurement and Automation Explorer. Maybe I could retrieve data from a 3rd party database back into Citadel if Citadel DB becomes corrupted or lost.
    I don't use ODBC logging now, so please excuse me if I come across as lacking in understanding your request. Could the hypertrend or other objects be programmed to log and/or retrieve data to and/or from the 3rd party ODBC database as well?
    Terry Parks, Engineering Analyst
    Terrebonne Parish Consolidated Government (T.P.C.G.)
    Public Works - Pollution Control

Maybe you are looking for

  • Removal of Balance Sheet Accounts Button on FAGLGVTR

    We are currently updating our SAP system with patches up to 19. However since the patch has been applied the report FAGLGVTR the balance sheet accounts button is missing. Did anyone have this problem ?

  • Reg. Provider Url set in weblogic-ejb-jar.xml

    have created an MDB which listens to an IBM MQ. I currently specify the path of the binding file by setting the provider_url in the weblogic-ejb-jar.xml An example is as follows:: <destination-jndi-name>Sample.Q</destination-jndi-name> <initial-conte

  • Printing quanties

    I just upgraded to PSCS5 from cs3. Win7 pro 64bit. All is well till I start printing. I print to 2 R1900s. The process goes like this: When I change the number of prints to, say, 3. The printer will print one print. The next time I try to print that

  • How do I achieve this effect?  Is it over-sharpening?

    I have a request to use this style on a photo.  I think it has something to do with over-sharpening but not sure how to best do it.  Advice greatly appreciated, thanks!

  • Need to enable Context Senstive DFF on iExpense 'General Information' Page.

    Hi Experts, I need to enable a DFF on a OA Framework page for iExpense. There are already two DFFs enable on the page but those are Global. Those are coming for every country, Now I need to enable one more DFF for a particular country - India. Could