Use of servlet http tunneling for client server communication

Hello I am having a problem connecting a simple client applet to a server application. I can connect the two directly using sockets. However, when I try to connect the two via a servlet the input stream cannot be accessed. The application is purely for demonstration. Here is some of the source code
A servlet for http tunneling
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SocketServlet extends HttpServlet
     ServletInputStream servletinput;
     ServletOutputStream servletoutput;
     Socket socket;
     DataOutputStream dataoutput;
     DataInputStream datainput;     
     public SocketServlet()
public void init(ServletConfig servletconfig) throws ServletException
super.init(servletconfig);
log("Socket servlet initialized.");
     public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
try
servletinput = request.getInputStream();
socket = new Socket( InetAddress.getByName( "127.0.0.1" ), 5000 );
dataoutput = new DataOutputStream( socket.getOutputStream() );
try
                    byte[] inbytes = new byte[1024];
                    servletinput.read( inbytes );
                    String inmessage = new String( inbytes );                    
                    dataoutput.writeBytes( inmessage );
catch(IOException ioex)
dataoutput.flush();
datainput = new DataInputStream( socket.getInputStream() );
servletoutput = response.getOutputStream();
try
byte[] outbytes = new byte[1024];
datainput.read( outbytes );
servletoutput.write( outbytes );
catch(IOException ioex)
servletoutput.flush();
servletoutput.close();
catch(Exception ex)
// Server.java
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Server extends JFrame {
private JTextField enter;
private JTextArea display;
DataOutputStream output;
DataInputStream input;
public Server()
super( "Server" );
Container c = getContentPane();
     enter = new JTextField();
     enter.setEnabled( false );
     c.add( enter, BorderLayout.SOUTH );
display = new JTextArea();
c.add( new JScrollPane( display ),
BorderLayout.CENTER );
setSize( 300, 150 );
show();
public void runServer()
ServerSocket server;
Socket connection;
int counter = 1;
try {
// Step 1: Create a ServerSocket.
server = new ServerSocket( 5000, 100 );
while ( true ) {
// Step 2: Wait for a connection.
display.setText( "Waiting for connection\n" );
connection = server.accept();
display.append( "Connection " + counter +
" received from: " +
connection.getInetAddress().getHostName() );
// Step 3: Get input and output streams.
output = new DataOutputStream(
connection.getOutputStream() );
input = new DataInputStream(
connection.getInputStream() );
display.append( "\nGot I/O streams\n" );
// Step 4: Process connection.
String message =
"SERVER>>> Connection successful";
output.writeBytes( message );
enter.setEnabled( true );
               display.append( "\nConnected\n" );
do {
try {
                    byte[] mess = new byte[1024];
input.read( mess );
display.append( "\n" + message );
display.setCaretPosition(
display.getText().length() );
               catch (IOException ioex )
} while ( !message.equals( "CLIENT>>> TERMINATE" ) );
// Step 5: Close connection.
display.append( "\nUser terminated connection" );
enter.setEnabled( false );
output.close();
input.close();
connection.close();
++counter;
catch ( EOFException eof ) {
System.out.println( "Client terminated connection" );
catch ( IOException io ) {
io.printStackTrace();
private void sendData( String s )
try {
output.writeBytes( "SERVER>>> " + s );
display.append( "\nSERVER>>>" + s );
catch ( IOException cnfex ) {
display.append(
"\nError writing object" );
public static void main( String args[] )
Server app = new Server();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
System.exit( 0 );
app.runServer();
// Fig. 21.4: Client.java
// Set up a Client that will read information sent
// from a Server and display the information.
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.zip.*;
public class Client extends Applet implements ActionListener {
private TextField enter;
private TextArea display;
DataOutputStream output;
DataInputStream input;
private Button button, button2;
URLConnection connection;
private byte[] bytes1, bytes2;
private String message, message2;
public void init()
setLayout( new BorderLayout() );
enter = new TextField( " Enter text here " );
enter.setEnabled( false );
enter.addActionListener( this );
add( enter, BorderLayout.NORTH );
display = new TextArea( 4, 30 );
     display.setEditable( false );
add( display, BorderLayout.CENTER );
     button = new Button( "Connect" );
     button.addActionListener( this );
     add( button, BorderLayout.SOUTH );
public void runClient()
Socket client;
try {
// Step 1: Create a Socket to make connection.
display.setText( "Attempting connection\n" );
          URL currentpage = getCodeBase();
          String protocol = currentpage.getProtocol();
          String host = currentpage.getHost();
          int port = 8100;
          String urlsuffix = "/servlet/SocketServlet";
          URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
          connection = dataurl.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-type", "application/octet-stream");
          connection.setUseCaches( false );
          display.append( "\nConnected to: " + host );          
// Step 2: Get the output streams.
output = new DataOutputStream(
connection.getOutputStream() );
          display.append( "\n got output stream\n" );
          // Step 3 get input connection
          try
          display.append( "\nAttempting to connect to input stream\n" );
               input = new DataInputStream( connection.getInputStream() );
               bytes1 = new byte[1024];
               input.readFully( bytes1 );
               display.append( "\nGot input stream\n" );
               message = new String( bytes1 );
               display.append( "\n" + message + "\n" );          
          catch ( IOException ioex )
          // Step 3: Process connection.
          enter.setEnabled( true );
          do {
          try {
bytes2 = new byte[1024];
          input.readFully( bytes2 );
          message2 = new String( bytes2 );
          display.append( "\n" + message2 );
          display.setCaretPosition(
          display.getText().length() );
          catch ( IOException ioex ) {
          display.append(
          "\nUnknown object type received" );
          } while ( !message.equals( "SERVER>>> TERMINATE" ) );
// Step 4: Close connection.
display.append( "Closing connection.\n" );
output.close();
input.close();
     catch (MalformedURLException mfe )
catch ( EOFException eof ) {
System.out.println( "Server terminated connection" );
catch ( IOException e ) {
e.printStackTrace();
private void sendData( String s )
try {
message = s;
output.writeBytes( "CLIENT>>> " + s );
display.append( "\nCLIENT>>>" + s );
catch ( IOException cnfex ) {
display.append(
"\nError writing object" );
public void actionPerformed( ActionEvent e )
     if ( e.getActionCommand() == "Connect" )
          runClient();
     else
          sendData( e.getActionCommand() );
public static void main(String args[])
Frame f = new Frame("Chat Client");
     Client c = new Client();
     c.init();
     f.add("Center", c);
     f.setSize(300, 150);
     f.show();
the connection appears to fail at client step 3, any help is super, thanks
Aidan

Hi,
In your client you are trying to open OutputStream even though you are not using it.
So there are two solutions here.
1. If you dont need OutputStream your code shoud look like this
try {
// Step 1: Create a Socket to make connection.
display.setText( "Attempting connection\n" );
URL currentpage = getCodeBase();
String protocol = currentpage.getProtocol();
String host = currentpage.getHost();
int port = 8100;
String urlsuffix = "/servlet/SocketServlet";
URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
connection = dataurl.openConnection();
//connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-type", "application/octet-stream");
connection.setUseCaches( false );
display.append( "\nConnected to: " + host );
// Step 2: Get the output streams.
//output = new DataOutputStream(
//connection.getOutputStream() );
//display.append( "\n got output stream\n" );
display.append( "\n Not interested in output stream\n" );
//Step 3 Inpustream related
// Step 4: Close connection.
display.append( "Closing connection.\n" );
//output.close();
input.close();
1. If you need OutputStream, close your OutputStream before even trying to get InputStream, your code should like this
try {
// Step 1: Create a Socket to make connection.
display.setText( "Attempting connection\n" );
URL currentpage = getCodeBase();
String protocol = currentpage.getProtocol();
String host = currentpage.getHost();
int port = 8100;
String urlsuffix = "/servlet/SocketServlet";
URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
connection = dataurl.openConnection();
//connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-type", "application/octet-stream");
connection.setUseCaches( false );
display.append( "\nConnected to: " + host );
// Step 2: Get the output streams.
output = new DataOutputStream(
connection.getOutputStream() );
display.append( "\n got output stream\n" );
//I'll do whateve I've to do with outputstream
//done with output stream closing
output.close();
//Step 3 Inpustream related
// Step 4: Close connection.
display.append( "Closing connection.\n" );
//output.close();
input.close();
hope this works
all the best,
Raj

Similar Messages

  • Can i use forms 9i or 10g for client/server applications

    Right now, we are using oracle 9i DB and developer suite 10g. I have to build a client/server application. In one of the OTN articles, it says that from forms 9i onwards, it's not supporting client/server applications. Do i have to use 6i for this.
    Thank You.
    Sree.

    That's right. Only web deployment is support from 9i onwards. Bad decision since Oracle seems to ignore their customer's view

  • What software usual is used to create installation package for client appli

    What software usual is used to create installation package for client application?

    >
    I mean the software that installed my application on client's machine. E.g. by click button Next, Next ...>Try clicking some of the 'buttons'(1) on the [webstart API examples|http://pscode.org/jws/api.html] page.
    (1) They are not HTML buttons, but links stylde to look vaguely like buttons. HTML buttons can be used just as easily, see [Launch JNLP App - launch style|http://pscode.org/jws/launch.html] for an overview of different launch styles.

  • Help-Is 9ias a necessity even for client server deployment of forms6i

    Hi
    Is 9Ias a necessity even for client server deployment of forms6i using developerSuite. I have been told that Oracle no longer markets Forms Server?
    Ganesh.

    No for client server deployment you don't need iAS.
    On the second issue Forms server (the bit of forms used to web deploy) is no longer sold stand-alone - it is part of the iAS suite.

  • Instant Message client - server communication

    Hi,
    I am writing an instant message application that has central server and many connected clients. When one client writes a message to the server, the server echoes the message to all concerned clients
    My server is a servlet, running on a J2EE web server. My client should run on Windows operating system and communicate with the WIN32 API.
    My problem is:
    The server is written in JAVA and my client should use the WIN32 API (in order to add its icon to the Windows tray for instance). How should I perform the client - server communication? What protocol/technology should I use? Should I write my client in C++ and from the server open a socket and perform HTTP requests? It looks too low level to me and not the �right� approach. Does it make sense to write my client in java and let it use JNI? And if yes, what is the preferred way of client � server communication?
    Is there any good reference I can use?
    Thanks

    The both alternates you are thinking over are fine. But the later one may cause some performance and memory issues.
    If you want to go with the first alternate, I suggest you to develope your owen server using ServerSocket and use your own protocol for communication between client and server over the sockets. Because using HTTP protocol will slow down your entire application. It adds overhead because each request passes through the servlet container.

  • How to list IP address from client on the Server (TCP/IP CLIENT SERVER COMMUNICATION)

    Excuse me,
    In this project I want to ask how to add list IP from client that connect to server.
    I have edited slightly the project.
    'SERVER
    Imports System.Net
    Imports System.Net.Sockets
    Imports System.Threading
    Imports System.Threading.Tasks
    Imports System.Reflection
    Public Class ServerForm
    Private _Listener As TcpListener
    Private _Connections As New List(Of ConnectionInfo)
    Private _ConnectionMonitor As Task
    Private Sub Button_Checked(sender As System.Object, e As System.EventArgs) Handles StartStopButton.CheckedChanged
    If StartStopButton.Checked Then
    StartStopButton.Text = "Stop"
    StartStopButton.Image = My.Resources.StopServer
    _Listener = New TcpListener(IPAddress.Any, CInt(PortTextBox.Text))
    _Listener.Start()
    Dim monitor As New MonitorInfo(_Listener, _Connections)
    ListenForClient(monitor)
    _ConnectionMonitor = Task.Factory.StartNew(AddressOf DoMonitorConnections, monitor, TaskContinuationOptions.LongRunning)
    Else
    StartStopButton.Text = "Start:"
    StartStopButton.Image = My.Resources.StartServer
    CType(_ConnectionMonitor.AsyncState, MonitorInfo).Cancel = True
    _Listener.Stop()
    _Listener = Nothing
    End If
    End Sub
    Private Sub PortTextBox_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles PortTextBox.Validating
    Dim deltaPort As Integer
    If Not Integer.TryParse(PortTextBox.Text, deltaPort) OrElse deltaPort < 1 OrElse deltaPort > 65535 Then
    MessageBox.Show("Port number between 1 and 65535", "Invalid Port Number", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    PortTextBox.SelectAll()
    e.Cancel = True
    End If
    End Sub
    Private Sub ListenForClient(monitor As MonitorInfo)
    Dim info As New ConnectionInfo(monitor)
    _Listener.BeginAcceptTcpClient(AddressOf DoAcceptClient, info)
    End Sub
    Private Sub DoAcceptClient(result As IAsyncResult)
    Dim monitorinfo As MonitorInfo = CType(_ConnectionMonitor.AsyncState, MonitorInfo)
    If monitorinfo.Listener IsNot Nothing AndAlso Not monitorinfo.Cancel Then
    Dim info As ConnectionInfo = CType(result.AsyncState, ConnectionInfo)
    monitorinfo.Connections.Add(info)
    info.AcceptClient(result)
    ListenForClient(monitorinfo)
    info.AwaitData()
    Dim doUpdateConnectionCountLabel As New Action(AddressOf UpdateConnectionCountLabel)
    Invoke(doUpdateConnectionCountLabel)
    End If
    End Sub
    Private Sub DoMonitorConnections()
    Dim doAppendOutput As New Action(Of String)(AddressOf AppendOutput)
    Dim doUpdateConnectionCountLabel As New Action(AddressOf UpdateConnectionCountLabel)
    Dim monitorInfo As MonitorInfo = CType(_ConnectionMonitor.AsyncState, MonitorInfo)
    Me.Invoke(doAppendOutput, "Server Started")
    Do
    Dim lostCount As Integer = 0
    For index As Integer = monitorInfo.Connections.Count - 1 To 0 Step -1
    Dim info As ConnectionInfo = monitorInfo.Connections(index)
    If info.Client.Connected Then
    If info.DataQueue.Count > 0 Then
    Dim messageBytes As New List(Of Byte)
    While info.DataQueue.Count > 0
    Dim value As Byte
    If info.DataQueue.TryDequeue(value) Then
    messageBytes.Add(value)
    End If
    End While
    Me.Invoke(doAppendOutput, "Message from IP: " + System.Text.Encoding.ASCII.GetString(messageBytes.ToArray))
    End If
    Else
    monitorInfo.Connections.Remove(info)
    lostCount += 1
    End If
    Next
    If lostCount > 0 Then
    Invoke(doUpdateConnectionCountLabel)
    End If
    _ConnectionMonitor.Wait(1)
    Loop While Not monitorInfo.Cancel
    For Each info As ConnectionInfo In monitorInfo.Connections
    info.Client.Close()
    Next
    monitorInfo.Connections.Clear()
    Invoke(doUpdateConnectionCountLabel)
    Me.Invoke(doAppendOutput, "Server Stoped")
    End Sub
    Private Sub UpdateConnectionCountLabel()
    ConnectionCountLabel.Text = String.Format("{0} Connections", _Connections.Count)
    End Sub
    Private Sub AppendOutput(message As String)
    If RichTextBox1.TextLength > 0 Then
    RichTextBox1.AppendText(ControlChars.NewLine)
    End If
    RichTextBox1.AppendText(message)
    RichTextBox1.ScrollToCaret()
    End Sub
    Private Sub ClearButton_Checked(sender As Object, e As EventArgs) Handles ClearButton.CheckedChanged
    If ClearButton.Checked Then
    RichTextBox1.Clear()
    End If
    End Sub
    End Class
    Public Class MonitorInfo
    Private _listener As TcpListener
    Public ReadOnly Property Listener As TcpListener
    Get
    Return _listener
    End Get
    End Property
    Private _connections As List(Of ConnectionInfo)
    Public ReadOnly Property Connections As List(Of ConnectionInfo)
    Get
    Return _connections
    End Get
    End Property
    Public Property Cancel As Boolean
    Public Sub New(tcpListener As TcpListener, connectionInfoList As List(Of ConnectionInfo))
    _listener = tcpListener
    _connections = connectionInfoList
    End Sub
    End Class
    Public Class ConnectionInfo
    Private _monitor As MonitorInfo
    Public ReadOnly Property Monitor As MonitorInfo
    Get
    Return _monitor
    End Get
    End Property
    Private _Client As TcpClient
    Public ReadOnly Property Client As TcpClient
    Get
    Return _Client
    End Get
    End Property
    Private _DataQueue As System.Collections.Concurrent.ConcurrentQueue(Of Byte)
    Public ReadOnly Property DataQueue As System.Collections.Concurrent.ConcurrentQueue(Of Byte)
    Get
    Return _DataQueue
    End Get
    End Property
    Private _Stream As NetworkStream
    Public ReadOnly Property Stream As NetworkStream
    Get
    Return _Stream
    End Get
    End Property
    Public Sub New(monitor As MonitorInfo)
    _monitor = monitor
    _DataQueue = New System.Collections.Concurrent.ConcurrentQueue(Of Byte)
    End Sub
    Private _LastReadLength As Integer
    Public ReadOnly Property LastReadLength As Integer
    Get
    Return _LastReadLength
    End Get
    End Property
    Private _Buffer(63) As Byte
    Public Sub AcceptClient(result As IAsyncResult)
    _Client = _monitor.Listener.EndAcceptTcpClient(result)
    If _Client IsNot Nothing AndAlso _Client.Connected Then
    _Stream = _Client.GetStream
    End If
    End Sub
    Public Sub AwaitData()
    _Stream.BeginRead(_Buffer, 0, _Buffer.Length, AddressOf DoReadData, Me)
    End Sub
    Private Sub DoReadData(result As IAsyncResult)
    Dim info As ConnectionInfo = CType(result.AsyncState, ConnectionInfo)
    Try
    If info.Stream IsNot Nothing AndAlso info.Stream.CanRead Then
    info._LastReadLength = info.Stream.EndRead(result)
    For Index As Integer = 0 To _LastReadLength - 1
    info._DataQueue.Enqueue(info._Buffer(Index))
    Next
    'info.SendMessage("Data Diterima " & info._LastReadLength & " Bytes")
    info.SendMessage("reply form server: " & info._LastReadLength & " Bytes")
    For Each otherInfo As ConnectionInfo In info.Monitor.Connections
    If Not otherInfo Is info Then
    otherInfo.SendMessage(System.Text.Encoding.ASCII.GetString(info._Buffer))
    End If
    Next
    info.AwaitData()
    Else
    info.Client.Close()
    End If
    Catch ex As Exception
    info._LastReadLength = -1
    End Try
    End Sub
    Private Sub SendMessage(message As String)
    If _Stream IsNot Nothing Then
    Dim messageData() As Byte = System.Text.Encoding.ASCII.GetBytes(message)
    Stream.Write(messageData, 0, messageData.Length)
    End If
    End Sub
    End Class
    'CLIENT
    Imports System.Net
    Imports System.Net.Sockets
    Public Class ClientForm
    Private _Connection As ConnectionInfo
    Private _ServerAddress As IPAddress
    Private Sub ClientForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    ValidateChildren()
    End Sub
    Private Sub ConnectButton_Checked(sender As Object, e As System.EventArgs) Handles ConnectButton.CheckedChanged
    If ConnectButton.Checked Then
    If _ServerAddress IsNot Nothing Then
    ConnectButton.Text = "Disconnect"
    ConnectButton.Image = My.Resources.StopServer
    Try
    _Connection = New ConnectionInfo(_ServerAddress, CInt(PortTextBox.Text), AddressOf InvokeAppendOutput)
    _Connection.AwaitData()
    Catch ex As Exception
    MessageBox.Show(ex.Message, "Error Connecting to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    ConnectButton.Checked = False
    End Try
    Else
    MessageBox.Show("Invlid IP Server", "Cannt Connect to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    ConnectButton.Checked = False
    End If
    Else
    ConnectButton.Text = "Connect"
    ConnectButton.Image = My.Resources.StartServer
    If _Connection IsNot Nothing Then _Connection.Close()
    _Connection = Nothing
    End If
    End Sub
    Private Sub SendButton_Click(sender As System.Object, e As System.EventArgs) Handles SendButton.Click
    If _Connection IsNot Nothing AndAlso _Connection.Client.Connected AndAlso _Connection.Stream IsNot Nothing Then
    Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(InputTextBox.Text)
    _Connection.Stream.Write(buffer, 0, buffer.Length)
    End If
    End Sub
    Private Sub ServerTextBox_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles IPTextBox.Validating
    _ServerAddress = Nothing
    Dim remoteHost As IPHostEntry = Dns.GetHostEntry(IPTextBox.Text)
    If remoteHost IsNot Nothing AndAlso remoteHost.AddressList.Length > 0 Then
    For Each deltaAddress As IPAddress In remoteHost.AddressList
    If deltaAddress.AddressFamily = AddressFamily.InterNetwork Then
    _ServerAddress = deltaAddress
    Exit For
    End If
    Next
    End If
    If _ServerAddress Is Nothing Then
    MessageBox.Show("Cannot resolve Server Address", "invalid Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    IPTextBox.SelectAll()
    e.Cancel = True
    End If
    End Sub
    Private Sub PortTextBox_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles PortTextBox.Validating
    Dim deltaPort As Integer
    If Not Integer.TryParse(PortTextBox.Text, deltaPort) OrElse deltaPort < 1 OrElse deltaPort > 65535 Then
    MessageBox.Show("Port number between 1 and 65535", "invalid Port number", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    PortTextBox.SelectAll()
    e.Cancel = True
    End If
    End Sub
    Private Sub InvokeAppendOutput(message As String)
    Dim doAppendOutput As New Action(Of String)(AddressOf AppendOutput)
    Me.Invoke(doAppendOutput, message)
    End Sub
    Private Sub AppendOutput(message As String)
    If RichTextBox1.TextLength > 0 Then
    RichTextBox1.AppendText(ControlChars.NewLine)
    End If
    RichTextBox1.AppendText(message)
    RichTextBox1.ScrollToCaret()
    End Sub
    Private Sub ButtonClear_Click(sender As Object, e As EventArgs) Handles ButtonClear.Click
    RichTextBox1.Clear()
    InputTextBox.Clear()
    End Sub
    End Class
    Public Class ConnectionInfo
    Private _AppendMethod As Action(Of String)
    Public ReadOnly Property AppendMethod As Action(Of String)
    Get
    Return _AppendMethod
    End Get
    End Property
    Private _Client As TcpClient
    Public ReadOnly Property Client As TcpClient
    Get
    Return _Client
    End Get
    End Property
    Private _Stream As NetworkStream
    Public ReadOnly Property Stream As NetworkStream
    Get
    Return _Stream
    End Get
    End Property
    Private _LastReadLength As Integer
    Public ReadOnly Property LastReadLength As Integer
    Get
    Return _LastReadLength
    End Get
    End Property
    Private _Buffer(63) As Byte
    Public Sub New(address As IPAddress, port As Integer, append As Action(Of String))
    _AppendMethod = append
    _Client = New TcpClient
    _Client.Connect(address, port)
    _Stream = _Client.GetStream
    End Sub
    Public Sub AwaitData()
    _Stream.BeginRead(_Buffer, 0, _Buffer.Length, AddressOf DoreadData, Me)
    End Sub
    Public Sub Close()
    If _Client IsNot Nothing Then _Client.Close()
    _Client = Nothing
    _Stream = Nothing
    End Sub
    Private Sub DoreadData(result As IAsyncResult)
    Dim info As ConnectionInfo = CType(result.AsyncState, ConnectionInfo)
    Try
    If info._Stream IsNot Nothing AndAlso info._Stream.CanRead Then
    info._LastReadLength = info._Stream.EndRead(result)
    If info._LastReadLength > 0 Then
    Dim message As String = System.Text.Encoding.ASCII.GetString(info._Buffer)
    info._AppendMethod(message)
    End If
    info.AwaitData()
    End If
    Catch ex As Exception
    info._LastReadLength = -1
    info._AppendMethod(ex.Message)
    End Try
    End Sub
    End Class
    //ScreenShot server
    http://prntscr[dot]com/5t1ol3
    //Screenshot client
    http://prntscr[dot]com/5t1odj
    source: code[dot]msdn[dot]microsoft[dot]com/windowsdesktop/Simple-Multi-User-TCPIP-43cc3b44

    I have a similar chat application. When the user attempts to connect, instead of sending a simple string, the client sends a serialized object(xml string) with all relevant login and session information, this includes the user's IP address. Once the server
    receives said information, depending on the type of TCP broadcast (a custom enumerated type) information from one user may be passed to a single user, or distributed to many users.
    If it helps, here is the TCPBroadcast object I use. But in order for your server to understand it, you kind of have to build your server and client somewhat around it.
    Option Strict On
    Option Explicit On
    Option Infer Off
    Namespace TCPChat
    Public Class TCPBroadcast
    Public Property Message As String
    Public Property BroadCastTime As DateTime
    Public Property DestUser As String
    Public Property OriginUser As String
    Public Property PasswordHash As String
    Public Property BroadcastSourceIP As String
    Public Property BroadCastType As TCPBroadcastType
    Public Property LoginUserName As String
    Public Property FailureReason As String
    Public Function XmlEncoding() As String
    Dim serializer As New Xml.Serialization.XmlSerializer(GetType(TCPBroadcast))
    Dim XML As String = String.Empty
    Using memStream As New IO.MemoryStream
    Using xmlWriter As New Xml.XmlTextWriter(memStream, System.Text.Encoding.UTF8) With _
    {.Indentation = 4, .Formatting = System.Xml.Formatting.Indented}
    serializer.Serialize(xmlWriter, Me)
    End Using
    XML = System.Text.Encoding.UTF8.GetString(memStream.ToArray)
    End Using
    Return XML
    End Function
    Public Function ToBinary() As Byte()
    Return System.Text.Encoding.UTF8.GetBytes(Me.XmlEncoding)
    End Function
    Public Shared Function FromBinary(binary As Byte()) As DeserializationResult
    Dim xml As String = System.Text.Encoding.UTF8.GetString(binary)
    Return FromXML(xml)
    End Function
    Public Shared Function FromXML(xml As String) As DeserializationResult
    Dim DeserializationResult As New DeserializationResult
    DeserializationResult.Error = False
    Try
    Dim deserializer As New Xml.Serialization.XmlSerializer(GetType(TCPBroadcast))
    Dim buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(xml)
    Using memStream As New IO.MemoryStream(buffer)
    DeserializationResult.tcpBroadCast = CType(deserializer.Deserialize(memStream), TCPBroadcast)
    End Using
    Catch ex As Exception
    DeserializationResult.Error = True
    DeserializationResult.ErrorMessage = ex.ToString
    DeserializationResult.AttemptedXML = xml
    End Try
    Return DeserializationResult
    End Function
    Public Class DeserializationResult
    Public [Error] As Boolean
    Public ErrorMessage As String
    Public tcpBroadCast As TCPBroadcast
    Public AttemptedXML As String
    Sub New()
    End Sub
    End Class
    Public Enum TCPBroadcastType
    AdministrativeMessage
    AuthenticationFailure
    AuthenticationSuccess
    ChatBroadcast
    CredentialsRequest
    Credentials
    DisconnectedByServer
    KeepAlive
    PrivateMessage
    ServerMessage
    SystemMessage
    UnableToProcessRequest
    End Enum
    End Class
    End Namespace
    “If you want something you've never had, you need to do something you've never done.”
    Don't forget to mark
    helpful posts and answers
    ! Answer an interesting question? Write a
    new article
    about it! My Articles
    *This post does not reflect the opinion of Microsoft, or its employees.

  • Cannot initialize SecurID client-server communications

    Hi!
    I've installed RSA/Ace Server on a machine where iPortal is running too. The path to ace server's config files is /opt/ace/data. We've configured SecurID Server Identifier Name as "Server000". We don't really know what this means, so we didn't change it.
    We've also followed the troubleshooting guide found in iPortal's Admin docs (telnet the config and helper's ports), and mimmic the portal procedures. However we get exactly the same error: cannot initialize client-server communications.
    We've also installed 2 Unix agents on 2 differente IP's. What kind of agents must be configured for authentication to work ?
    What can be causing this ?

    I've experience to connect the ace server with portal server. The configuration is very simple and I think most of the setting in your portal is correct. One thing you should make sure is to config the portal server machine as a client to the ace server and it work. (In your case, it is same machine).
    Clive Chan

  • Can i use forms 9i for client server applicaitons

    Hi,
    I have to build a client/server application.Right now, we are using oracle 9i and developer suite 10g. In one of the articles on OTN, it says that from forms 9i onwards, it's not supporting client/server model. Do i have to use 6i for this.
    Thank you.
    Sree.

    The last Forms version that can be run in c/s mode is 6i.

  • JavaFX as a SaaS/ How good is it for Client-Server work?

    I was under the impression that FX could be used to produce a Client-Server application as well as SaaS.
    a member of another forum said "I'm sure you meant to say "Desktop". JavaFX will not be making inroads on the web as a client-side technology."
    To which I said
    There have been examples of FX used with EE
    http://www.oracle.com/technetwork/java/javafx/samples/index.html
    http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm
    Sales Dashboard (DataApp)
    DataApp is a client-server application for a fictional global automobile company called Henley Car Sales. Automobile sales are simulated on an EJB server using JavaDB, and the data is available via Derby and a RESTful web service. The client demonstrates a variety of data presentations by using a mix of FXML and JavaFX.
    I thought originally that JavaFX was "Desktop" only also, until I found this example. I couldn't get it to run due to some weird Database line read issue that others also had. I'm not sure if this is now due to FX's integration, or if this was something new, but I believe I have seen another FX client-server app as well.
    I'm not that familiar with the client-server side of Java yet, so if you have other Information I would like to know, because I am looking to design a Client-Server app with FX, and I don't see why it would be an issue, unless there are huge limitations."
    He ended up saying "Those are still desktop apps. Sure, they are client-server in that they connect to a remote database. But they are still traditional fat-client apps rather than web-based thin-client SAAS web applications which, these days, most people will think of when you say "client".
    My point is to be more precise when you use the word "client".
    But if your point is just that JavaFX is taking over from Swing for the limited areas in which Swing is used, I have no insight into that area."
    Now I don't really like attitudes when I get my question answered, but the high and mighty needs to stop. It clearly says Client-Server so I don't know why it's being denounced by this dude who thinks he obviously knows better.
    Anyways he talks about it only being able to connect to a DB, to which it says it uses EE tech such as EBJ, Restful, and Derby, so that's more than just DB right(I don't know since I havent' learned that yet)?
    It seems as if he's saying that only EE code can go up on a server? Or can SE code go up there as well?
    I'm looking to design a SaaS software with FX, so if this isnt' possible I would like to know possible other options(or just having all of the gui work on the client, and the rest on the backend)???
    Thanks!
    ~KZ
    Edited by: KonradZuse on Apr 30, 2013 11:26 AM

    This response is not a tutorial, I hope it gives you some verbiage to use in further searches.
    SaaS to me means that the service is running on the server. If you have the server and permission to run java apps there then you can use Java FX by having the server shuttle requests to the Java FX app. But this is probably not the intent of Saas (it would be more appropriate to use a java implemented web service).
    If you are using Netbeans then it is very easy to create demo projects; use "File/New Project" to run them on your local computer.
    Example File/New Project/Java Web/Web Application will give you a hello world web site very quickly. This will 1) start either tomcat or glassfish as the server. 2) launch an html page with "hello world". then you can use java script to talk with the server via ajax. Using this approach you are going to need to study JSP or J2EE stuff.
    After this is running you could start one of the Java Fx examples in Netbeans: File / New Project / Samples / WebViewBrowser. This will start a javaFX app that acts like a browser and runs on the client.
    So, start the "hello world" app in netbeans by right clicking it in the project pain and selecting "debug". Then start the webviewBrowser app the same way to load that web page that has "hello world" in it as all browsers do. In the WebviewBrowser (which is java fx) you can get at the javascript in the web page and do all kinds of stuff. You'll need to search for webviewBrowser examples.
    The above all assumes a Netbeans solution. But, as you probably know, there are no rules. The server can be in C++ and the client in C (or any other language). The server and client usally communicate via http or tcp. So you could have a server written in java (maybe J2ee or you can rewrite a http server from scratch which isn't that hard - search for "HttpServletRequest and HttpSession" ) and the client can be in Java FX (where the Java FX talks directly with the server via http (no javascript or web page in the middle) again there are probably hundreds of libraries to talk to a http server).
    I use HttpServletRequest and HttpSession on the server side with MySQL and xml. On the client I use javaScript but I am moving to a strictly Java FX solution. This will give me close to 100% java on both sides and for my purposes this will work. (I may need a little html in the middle for drag and drop installation.) I am hoping that work continues with porting Java FX to most devices: Android, IOS, WinPhone. It is already on Linux, Windows Desktops and Mac.
    Edited by: KevinPas on May 1, 2013 9:50 AM
    Edited by: KevinPas on May 1, 2013 9:56 AM

  • Using Windows Azure File Service for Symbols Server

    Hi,
    I am trying to understand how to use the Windows Azure File Service (http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx) for a Symbols Service.  I have not been able to find any documentation
    to help guide me with this specifically.  Most of the guides I have found discuss creating a VM and File Server in Azure.
    Thanks!

    Hi,
    Azure Files can only be used from an Azure VM within the same region as the storage account.
    it will work when setup a symbol server for azure VMs, if you trying to setup a symbol server for external client machines then this won’t work.
    Regards
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Framework for client-server Architecture in Java !!!! With swing

    Hi,
    Considering the scenario where we are having the Client-Server application and the rich clients at the client place , based on the frames.I have though of the logic as :
    Client -----------> ClientComponentframeWorkObject(Genric Objects) ---------> reading the data from the configurable files to find where to take the user action ---------> will call the Servercomponetobject(Generic objects) can be Servlet or just a object which connects to the server(DB).I have been able to find the open-source frame work at the Apache ,all covering the server-side framework so i though of doing some work with the framework covering the client(swing) -server Archetect.Even I dont know how the existing server side framework support the swing client.
    I would appericiate if someone who had worked on the client server requirement with java , could share the knowledge about the framework being used in the existing work.
    regards
    Vicky

    Hi,
    GENERIC CLIENT COMPONENT:
    package com.nst.clientcomp;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public abstract class ClientComp extends JFrame
      protected JFrame currentframe;     
      protected JPanel  panel;
      public ClientComp()
           // To decide if the ClientComp to be Frame or the Panel.
        //panel=this;     
        //currentframe=new JFrame();
        panel=new JPanel();     
        currentframe=this;
      // Just Concentrate on the GUI , look and feel here .......And the user action will generate
      // generate the event which should call the callNextView()..The component developer have to
      // concentrate on the writing the display() and the callNextView()..
      public abstract void display() ;
      // This is the Final action.Template Pattern being Called
      public String action()
           readServerObj();
           processContent();
           display();              
           return null;
       Reading of the value object which is being Passes from the Server.As per the Design it is
       called VOFS and will be read here.Here
       1) Connect to the Server
       2) Pass the VOFC through the socket connection
       3) Also obtain the VOFS(Value object from server) 
       In certain application it can be implemented here
      public Object readServerObj()
            System.out.println("Hello from ServerObj!!! Should be implemented ");
            return null;
       Processing the Sever Value Object, which is basically as VOFS.It is processed by the
       Client.And infact the Value object from Client(VOFC) should be generated here for next
       user interaction from the Client.
      public void processContent()
            System.out.println("Hello from processContent !!! Should be implemented ");
      // Clear the Frame
      private void cleanUp()
         currentframe.dispose();
         Contains the place where next view takes.Before this is invoked the cache copy of the
         StateObject should be stored in the appropriate Data Structure......      
      public void callNextView(ClientComp com)                     
            panel.removeAll();
            com.action();
            cleanUp();
    }   COMONENTS AS PER THE FRAMEWORK :
    package com.nst.clientcomp;
    import javax.swing.*;
    import java.awt.event.*;
    public class Comp1 extends ClientComp implements ActionListener
      JTextField t,t1;     
    //Default display , displaying the screen.This should be the abstract method
      public void display()
        JLabel l=new JLabel("UserName");
        t=new JTextField(10);
        JLabel l1=new JLabel("Password");
        t1=new JPasswordField(10);
        t.setText("admin");
        t1.setText("admin");
        JButton b=new JButton("Login");
        b.addActionListener(this);
           panel.add(l);
           panel.add(t);
           panel.add(l1);
           panel.add(t1);
           panel.add(b);
           currentframe.getContentPane().add(panel);
           currentframe.setSize(400,400);
           currentframe.setVisible(true);      
      public static void main(String ar[]) throws Exception     
           ClientComp c1 = (ClientComp)(Class.forName(ar[0])).newInstance();
           c1.action();             
           System.out.println("Hello11");
      public void actionPerformed(ActionEvent e)
           //Do someprocessing if required
           if(t.getText().equals("admin")&&t1.getText().equals("admin"))
           callNextView(new Comp2());  
           else
            System.out.println("invalid login");     
    } Similarly you can develop the other components and you have to take care of the display() and the user action Event which eventually calls the callNextView.I hope there might be the cases where this has been implemented ..
    Regards
    Vicky

  • Code sample HTTP get for J2EE server

    Hi,
    could somebody pls. provide a code sample to access a SAP WAS J2EE server via HTTP GET?
    I needed this to get a SAP Logon ticket issued to my web dynpro application. Basically I am imitating a logon to the server in order to get the logon ticket in return. This is the same as logging on using IE to http://server.domain:5xxxx. Should my user credentials be valid, the HTTP get would return a SAP Logon ticket (among other data).
    Thank you,
    Rene

    how would you direct the GET requests to one servlet and the POST requests to the other?
    Wouldn't they need to pass thru' yet another servlet to decide which is which (GET or POST), and redirect them accordingly?
    I would have both GET and POST handled by the same single-point-of-entry servlet. For example, not all data is sent to the server via a POST - you can send form data via a GET, using name/value pairs in the url.

  • Need Help for client - server - client question [Sockets]

    Hi
    I have read the http://java.sun.com/docs/books/tutorial/networking/sockets/index.html tutorial and made this Knock Knock Application.
    But now, I want that one client can view all the other clients which are connected to the server, and interract with a selected cleint over the server (client - server - client).
    But I have no idea how to build such a registration concept?
    A concrete hint (or link) how to realise this would be very helpful. I searched all the internet for examples, but I dont found a simple example.
    Thanks in advance
    greeds

    wSam,
    It appears that Sun considers RMI to be simpler, although less efficient than the alternative:
    http://java.sun.com/developer/technicalArticles/ALT/sockets/
    This article also talks about object serialization, which I am a fan of. Suppose that you want to send a data structure containing lots of information (like all connected users). You can actually pass an object (rather than text) across the network using ObjectOutputStream and receive it on the other end with ObjectInputStream. You might create your own Command class for passing objects between the client and server instead of using RMI. The Command class might hold flags that indicate which method should take place on the remote machine (i.e. send chess move command).

  • ECM11g: How to enforce HTTPS access for Content server console

    Hi,
    We have a requirement of accessing Content Server console (https://<hostname>:<port>/cs) with https protocol only. If a user sends a http request (http://<hostname>:<port>/cs) it should get converted to https.
    The managed server is running with non SSL port. The request is comming from Apache where we have used the parameter "WLProxySSL" to enforce the https, however its not getting enforced for Content Server URL.
    Any help in this regard is highly appreciated.
    Thanks.

    Sorry, I forgot to say that
    i don't want to use the popup
    window that appears when JWS
    encounter an URL that requires
    basic authentication.
    In fact, I don't want to have to enter
    login/password for updates each time
    I start my application with JWS.

  • Pjc for client-server mode

    hi,
    i have been using pjc for customized text field and text area and have successfully implemented it on windows and sun solaris. we have used pjc for working in non english character set so that the user can directly type in the required character set without any supporting application to enable new keyboard mapping. but i have a serious problem.
    these customized components work only on the webforms mode.i.e. on browser or applet. they dont work in the normal client server mode. is it possible that i can have them running in the normal runtime also. if yes then how and if not what is the work around for achieving the same without much effort.
    awaiting a prompt reply.
    thanks in advance,
    regards,
    Yousuf.
    Delhi.

    Dear Yousof,
    I want to do the same thing that u'vve already acheived, I want to customize oracle forms texfields and instead of EXTENDING VTextfield I want to extend JTextfield and ofcourse implementing IView interface.
    But I get problems, would u mind be kind enough to instruct me in doing that?
    Best regrds,
    Sasan

Maybe you are looking for

  • Having problem with adding and reading dates to/from database !!!

    Hi I am new in J2ME I am trying to code a simple software. My problem is with dates. I have a datefield on my menu and the user will choose the date from here. By default, datefield shows todays date. But when I try to write that date to database usi

  • Acrobat Pro XI . converting of excel and word to pdf

    After installing Acrobat Pro XI two days ago, the conversions of excel and word to pdf are less than optimal.  Poor fonts, color and sometimes blurry.

  • Inspire 6700 DVD connection

    I have a set of Inspire 6700 speakers connected to my present DVD player. The DVD player has six phono outputs: L, R, RL, RR, Ctr, Sub. I've used phono to 3.5mm converters to connect these into the three input sockets on the 6700 system. I am now loo

  • About bitmap object

    i want to load my icons set from external png so that i can change/update them without recompile my swf. my question is: save those icons in separate files like icon_00.png, icon_01.png, icon_02.png and attach them to display object. or just save the

  • Unable to connect to BI System from Visual Composer

    Hie there,   I am unable to connect to my BI system from Visual Composer   The error message which I obtain upon clicking on 'Find Data' and selecting one of the many Systems list are as follows :-   Error - 30014 Search returned an erro Failed to co