Troubleshooting guide
233
15: Creating push applications
bytesRead = ins.read(buffer);
System.out.println(buffer);
if (bytesRead <= 0) break;
outs.write(buffer, 0, bytesRead);
}
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit (0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main (String args[]) {
new HTTPPushServer().show ();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel _panel;
private javax.swing.JTextField _textField;
private javax.swing.JTextArea _textArea;
private javax.swing.JTextField _pinField;
private javax.swing.JTextArea _label;
private javax.swing.JTextArea _notification;
private javax.swing.JButton _sendButton;
private javax.swing.JRadioButton _rimButton;
private javax.swing.JRadioButton _papButton;
private javax.swing.ButtonGroup _buttonGroup;
private javax.swing.JScrollPane _scrollPane;
// End of variables declaration//GEN-END:variables
public class NotificationThread extends Thread {
public void run()
{
try {
System.out.println(“Waiting for notification on port “ + 7778 + “...”);
while (true)
{
ServerSocket serverSocket = new ServerSocket(7778);
serverSocket.setSoTimeout(120000);
try {
Socket clientSocket = serverSocket.accept();
_notification.setText(“Received notification:”);
InputStream input = clientSocket.getInputStream();
StringBuffer str= new StringBuffer();
int byteRead = input.read();
while ((byteRead != -1) && (input.available() > 0))
{
str.append((char)byteRead);
byteRead = input.read();
}
_notification.append(str.toString());
PrintWriter output = new
PrintWriter(clientSocket.getOutputStream());