2 Oracle Clients in the server
Guys,
we have a server which has an Oracle 8.1.7 installed. Since we developed a new .net application that requires Oracle 9iR2 Client, we have to install an Oracle 9iR2 also on the same machine. However, we are having problems executing stored procs that has an out parameter particulary with a clob datatype. I assume that the .net is still using the old oledb drivers of 8.1.7 instead of 9iR2. What should we do?
I have a somewhat similar issue. I think your assumption may be wrong though:
"However, because the Oracle Provider for OLE DB is a COM component, only one instance can be active at a time. This means that a later OLE DB installation will render the previous one inactive."
Similar Messages
-
Oracle client for siebel server configuration
Hi ,
To install siebel as prerequisite we are installing oracle client on the siebel server machine. Our client is providing ldap.ora instead of tnsnames.ora file. Through out my earlier projects we used to have tnsnames.ora entry which is having connection details of database. CAn you Please confirm instead of having tnsnames.ora , can we use ldap .ora which is having Db server details in it. Have you ever seen other clients using this way without tnsnames.ora for siebel installation.
Can you please provide any documentation which confirms that we must need tnsnames.ora, not ldap.ora.
Thanks much in advance.Hi,
Have a look at these documents
http://docs.oracle.com/cd/E11882_01/network.112/e10835/ldap.htm#NETRF011
Is It Possible To Use Ldap.Ora On The Client To Get Tnsname Entries From An Oid? (Doc ID 461151.1)
Using TNS_ADMIN with LDAP.ORA and Net Manager (Doc ID 189627.1)
What Is The Search Order For The LDAP.ORA File ? (Doc ID 363283.1)
Thanks,
Krishna -
ODAC vs oracle client on Windows server 2008
Hello,
Apologies in advanced if this is a silly question.
I am currently working with a .NET application team that connects to oracle. I am attempting to host there application on my servers. I have tested connectivity to there DB with SQLplus using the 11.2 oracle client.
The application team is asking me to install Oracle Developer tools on the server to replace the client. One of the members of the operate team told me that this is a requirement for there application to talk to oracle. I don't necessarily think they are correct, are there any oracle dependence that would require to ODT to be installed to run a .net application on a server? It's my understanding that ODT is primary used as a plug in for VS.
Thanks in advance,
Dax873574 wrote:
Hello,
Apologies in advanced if this is a silly question.
I am currently working with a .NET application team that connects to oracle. I am attempting to host there application on my servers. I have tested connectivity to there DB with SQLplus using the 11.2 oracle client.
The application team is asking me to install Oracle Developer tools on the server to replace the client. One of the members of the operate team told me that this is a requirement for there application to talk to oracle. I don't necessarily think they are correct, are there any oracle dependence that would require to ODT to be installed to run a .net application on a server? It's my understanding that ODT is primary used as a plug in for VS.
Thanks in advance,
DaxDax,
You are correct that you do not need the Oracle Developer Tools for Visual Studio to be installed on the server. What the team is probably meaning to ask is for you to install "Oracle Data Provider for .NET" which is also part of the ODAC install. They probably got the two names mixed up. -
Requires Oracle client for windows server 2008 Version 6.1
Hello
I am using Windows 2008 Server Version 6.1 (64 Bit). I want to install Oracle client on this server. Which version is suitable for my requirement and from where i can download it.
Thanks
Sijo Thomasuser12248518 wrote:
I am in the same boat, I have downloaded what was told to download and it doesn't install it keeps saying "Unknown" 3 times in a popup when I try to install.Oracle has roughly 3,000 products. You downloaded 'what you were told' - one of those 3,000 products. And it didn't work.
The amount of information you provide is surprisingly sparse, assuming you want assistance.
So - if you want help, you might wnat to provide some information:
- the operating system (including edition, and major service pack if WIndows, or distro && major/minor release and kernel if *nix)
- the URL froim which you downloaded
- the country yuo are in (since ORacle could redirect to several sitres based on region)
- the command or executable, including directory path, you run or double-click on
- the 'exact' error message, or if a generic one like "Unknown", perhaps a screen shot to convince us that it is actually such a generic message
It's just a suggestion, but answering in such detail actually tells us you are serious about resolving the issue - you put in effort, and that may convince us to return some effort. -
Hello. I would like to write async tcp client and server. I wrote this code but a have a problem, when I call the disconnect method on client or stop method on server. I can't identify that the client or the server is no longer connected.
I thought I will get an exception if the client or the server is not available but this is not happening.
private async void Process()
try
while (true)
var data = await this.Receive();
this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
catch (Exception exception)
How can I determine that the client or the server is no longer available?
Server
public class Server
private readonly Dictionary<IPEndPoint, TcpClient> clients = new Dictionary<IPEndPoint, TcpClient>();
private readonly List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
private TcpListener tcpListener;
private bool isStarted;
public event Action<string> NewMessage;
public async Task Start(int port)
this.tcpListener = TcpListener.Create(port);
this.tcpListener.Start();
this.isStarted = true;
while (this.isStarted)
var tcpClient = await this.tcpListener.AcceptTcpClientAsync();
var cts = new CancellationTokenSource();
this.cancellationTokens.Add(cts);
await Task.Factory.StartNew(() => this.Process(cts.Token, tcpClient), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
public void Stop()
this.isStarted = false;
foreach (var cancellationTokenSource in this.cancellationTokens)
cancellationTokenSource.Cancel();
foreach (var tcpClient in this.clients.Values)
tcpClient.GetStream().Close();
tcpClient.Close();
this.clients.Clear();
public async Task SendMessage(string message, IPEndPoint endPoint)
try
var tcpClient = this.clients[endPoint];
await this.Send(tcpClient.GetStream(), Encoding.ASCII.GetBytes(message));
catch (Exception exception)
private async Task Process(CancellationToken cancellationToken, TcpClient tcpClient)
try
var stream = tcpClient.GetStream();
this.clients.Add((IPEndPoint)tcpClient.Client.RemoteEndPoint, tcpClient);
while (!cancellationToken.IsCancellationRequested)
var data = await this.Receive(stream);
this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
catch (Exception exception)
private async Task Send(NetworkStream stream, byte[] buf)
await stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
await stream.WriteAsync(buf, 0, buf.Length);
private async Task<byte[]> Receive(NetworkStream stream)
var lengthBytes = new byte[4];
await stream.ReadAsync(lengthBytes, 0, 4);
var length = BitConverter.ToInt32(lengthBytes, 0);
var buf = new byte[length];
await stream.ReadAsync(buf, 0, buf.Length);
return buf;
Client
public class Client
private TcpClient tcpClient;
private NetworkStream stream;
public event Action<string> NewMessage;
public async void Connect(string host, int port)
try
this.tcpClient = new TcpClient();
await this.tcpClient.ConnectAsync(host, port);
this.stream = this.tcpClient.GetStream();
this.Process();
catch (Exception exception)
public void Disconnect()
try
this.stream.Close();
this.tcpClient.Close();
catch (Exception exception)
public async void SendMessage(string message)
try
await this.Send(Encoding.ASCII.GetBytes(message));
catch (Exception exception)
private async void Process()
try
while (true)
var data = await this.Receive();
this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
catch (Exception exception)
private async Task Send(byte[] buf)
await this.stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
await this.stream.WriteAsync(buf, 0, buf.Length);
private async Task<byte[]> Receive()
var lengthBytes = new byte[4];
await this.stream.ReadAsync(lengthBytes, 0, 4);
var length = BitConverter.ToInt32(lengthBytes, 0);
var buf = new byte[length];
await this.stream.ReadAsync(buf, 0, buf.Length);
return buf;Hi,
Have you debug these two applications? Does it go into the catch exception block when you close the client or the server?
According to my test, it will throw an exception when the client or the server is closed, just log the exception message in the catch block and then you'll get it:
private async void Process()
try
while (true)
var data = await this.Receive();
this.NewMessage.Invoke(Encoding.ASCII.GetString(data));
catch (Exception exception)
Console.WriteLine(exception.Message);
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
By the way, I don't know what the SafeInvoke method is, it may be an extension method, right? I used Invoke instead to test it.
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. -
Sending a certificate form the client to the server... how to ?
how can I send a certificate from the client to the server trough a Java code ??
Short answer: You specify a keyStore.
Either via command line using the -Djavax.net.ssl.keyStore=keystorefile property,
or in Java code:
char[] passphrase = "password".toCharArray();
SSLContext ctx = SSLContext.getInstance("TLS", "SunJSSE");
// KeyStore for the SSL client certificate
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream("client-cert.p12"), passphrase);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509", "SunJSSE");
keyManagerFactory.init(keyStore, passphrase);
// keyStore for trusted server certs or CAs
KeyStore trustedKeyStore = KeyStore.getInstance("JKS");
trustedKeyStore.load(new FileInputStream("verisign-test-cert"), passphrase);
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509", "SunJSSE");
trustManagerFactory.init(trustedKeyStore);
ctx.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
SSLSocketFactory sslSocketFactory = ctx.getSocketFactory();
HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
// open the http connection to the party
myConn = (HttpsURLConnection)myURL.openConnection(); -
Generated either client or the server
which logs can be generated either client or the server?
I must be having a déjà vu... No, wait... you have posted this before:
logs can be generated -
Using Notes and Oracle Client in the same application on Linux crashes
This thread is copied from a thread of the same name under Database - General, since I cannot get any replies there.
Could someone from Oracle PLEASE comment on this.
Our application on Linux loads the Notes client libraries and then the Oracle client libraries. The application will crashes when connectimg to an Oracle server. This is because the T_* symbols in libnnz11.so get fixed up into libnotes.so rather than locally into libnnz11.so where the functions are defined.
#10 0xb4779ea6 in T_malloc () from /opt/ibm/lotus/notes/libnotes.so
#11 0xae7ca050 in CMP_reallocNoCopy ()
from /opt/oracle/product/10.2/db_1/lib/libnnz11.so
#12 0xae7ccf7b in CMP_OctetStringToCMPInt ()
from /opt/oracle/product/10.2/db_1/lib/libnnz11.so
#13 0xae7c91fd in A_X931RandomInit ()
from /opt/oracle/product/10.2/db_1/lib/libnnz11.so
#14 0xaec09e0d in ztcriv ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#15 0xaec09cef in ztcrbp ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#16 0xaec09ca4 in ztcr2seed ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#17 0xaec09c54 in ztcrseed3 ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#18 0xaeb40683 in ztcsh ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#19 0xaea631c4 in kpusattr ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#20 0xaea7847e in OCIAttrSet ()
from /opt/oracle/product/10.2/db_1/lib/libclntsh.so.10.1
#21 0xb081cb9f in COCIObject::Connect ()
from /opt/criticalpath/common/bin/libor9i.so
We have circumvented the problem for the time being by making sure that we load the Oracle libraries before Notes, but we cannot go with that as a long term solution.
In my opinion the Oracle library is wrongly linked since all the T_* functions are defined in libnnz11.so. When we load Oracle first, the loader debug trace shows the correct fixups. When we load Notes first, the loader trace shows the incorrect fixups. We are using dlopen(libor9i.so, RTLD_LOCAL) for Oracle and dlopen(libnotes.so, RTLD_LOCAL) for Notes. libor9i.so has a dependency on libclntsh.so.10.1.
An opinion would really be appreciated.
Thanks,
John UnsworthThanks again.
We don't have an Oracle support contract because we do not use Oracle ourselves. We supply an application that synchronises data between multiple data servers and server types, of which Oracle is one and Notes is another, as well as LDAP servers and many other types.
Producing a full resolved binary is therefore not an option since the types of data server are configured when the apploication is installed, and then the client software for each server is loaded as required.
The end user of the application supplies the client libraries and has a support contract for the servers, in particular Oracle and Notes in this case. So the other option is for the end user to raise a ticket using his support contract, but he is reluctant to do that since he considers that this is our problem as we supply the application that is having the problem. So we are in a dead water area. We do not want to take out a support contract just to get what is an Oracle product problem resolved. I imagine that this problem is something that has not been encountered before, because our use of the client library in conjunction with other client libraries is probably unusual.
So that is why I am hoping, without any success so far, that someone from Oracle will pick this up. -
Any docs on HOW TO INSTALL ORACLE CLIENT ON OBIEE SERVER?`
Thanks...
Generally speaking the way to installing Oracle Client does not depend directly on the product that is going to use it
If some product requires some specific Oracle Client versions or Oracle Client configurations you should find this information in the product documentation (i.e OBIEE Server) and not in Oracle Client documentation.
You can find Oracle Client documentation (named "Database Client") in the Installation sections of tahiti.oracle.com. For example for 11.2: http://www.oracle.com/pls/db112/portal.portal_db?selected=11&frame=#microsoft_windows_installation_guides. -
Oracle Client in Citrix Server
It is fail to install Oracle8i Client Release 3 (8.1.7) in our Citrix Metaframe server via Add/Remove programs. After I select the location of Client 8i installation path and press Next button, nothing was appeared. The oracle client installation never start.
But I can install the oracle client in any desktop machine using this CDROM and I can use Add/Remove program in Citrix server to install Visual Basic program and other program.
I don't know why nothing happen when I execute the Oracle client installation.
Please help and advise.
Patrick LeeBug in 817
If your running from the CD, then you need to copy all the files to your network somewhere.
Once on the network/hard disk, search the contents of the CD for a file named symcjit.dll and rename to symcjit.old. There will be more than 1 of these files, and you must rename all of them.
Then run setup again. -
Problem connecting Oracle client 11g to server 11g
I'm trying to connect a second computer to the Oracle Server computer with a client. I have a listener running, and correct settings for the net manager. The error that I get is:
"the test did not succeed, ORA 12170: TNS connect timeout occurred. there may be an error in the fields entered (they are correct), or the server may not be ready for a connection. Is there something I have to do with the router? I'm on a wireless connection is there any problem with that?user8953579 wrote:
I'm trying to connect a second computer to the Oracle Server computer with a client. I have a listener running, and correct settings for the net manager. The error that I get is:
"the test did not succeed, ORA 12170: TNS connect timeout occurred. there may be an error in the fields entered (they are correct), or the server may not be ready for a connection. Is there something I have to do with the router? I'm on a wireless connection is there any problem with that?Oracle is oblivious to the fact that the net is wireless.
We need to see your tnsnames.ora and sqlnet.ora files on your client computer.
We need to see the results of
lsnrctl statusfrom the database server
In addition to the following boilerplate comments, I've been doing a series of articles on tns connection issues at edstevensdba.wordpress.com
=================================
A couple of important points.
First, the listener is a +server side only+ process. It's entire purpose in life is to receive requests for connections to databases and set up those connections. Once the connection is established, the listener is out of the picture. It +creates+ the connection. It doesn't +sustain+ the connection. One listener, with the default name of LISTENER, running from one oracle home, listening on a single port, will serve multiple database instances of multiple versions running from multiple homes. It is an unnecessary complexity to try to have multiple listeners or to name the listener as if it belongs to a particular database. That would be like the telephone company building a separate switchboard for each customer.
Additional notes on the listener: One listener is capable of listening on multiple ports. But please notice that it is the *listener* using these ports, not the database instance. You can't bind a specific listener port to a specific db instance. Similarly, one listener is capable of listnening on multiple IP addresses (in the case of a server with multiple NICs) But just like the port, you can't bind a specific ip address to a specific db instance.
Second, the tnsnames.ora file is a +client side+ issue. It's purpose is for address resolution - the tns equivalent of the 'hosts' file further down the network stack. The only reason it exists on a host machine is because that machine can also run client processes.
Assume you have the following in your tnsnames.ora:
{code}
larry =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = curley)
{code}
Now, when you issue a connect, say like this:
{code}
$> sqlplus scott/tiger@larry
{code}
tns will look in your tnsnames.ora for an entry called 'larry'. Finding it, tns sends a request through the normal network stack to (PORT = 1521) on (HOST = myhost) using (PROTOCOL = TCP), asking for a connection to (SERVICE_NAME = curley).
Where is (HOST = myhost) on the network? When the request gets passed from tns to the next layer in the network stack, the name 'myhost' will get resolved to an IP address, either via a local 'hosts' file, via DNS, or possibly other less used mechanisms. You can also hard-code the ip address (HOST = 123.456.789.101) in the tnsnames.ora.
Next, the standard networking process delivers the message to port 1521 on myhost. Hopefully, there is a listener on myhost configured to listen on port 1521, and that listener knows about SERVICE_NAME = curley. If so, the listener will spawn a server process to act as the intermediary between your client and the database instance. Communication to the server process will be on a randomly selected available port. At that point the listener is out of the process and continues to user port 1521 to await other connection requests.
What can go wrong?
First, there may not be an entry for 'larry' in your tnsnames. In that case you get "ORA-12154: TNS:could not resolve the connect identifier specified" No need to go looking for a problem on the host, with the listener, etc. If you can't place a telephone call because you don't know the number (can't find your telephone directory (tnsnames.ora) or can't find the party you are looking for listed in it (no entry for larry)) you don't look for problems at the telephone switchboard.
Maybe the entry for larry was found, but myhost couldn't be resolved to an IP address (say there was no entry for myhost in the local hosts file). This will result in "ORA-12545: Connect failed because target host or object does not exist"
Maybe there was an entry for myserver in the local hosts file, but it specified a bad IP address. This will result in "ORA-12545: Connect failed because target host or object does not exist"
Maybe the IP was good, but there is no listener running: "ORA-12541: TNS:no listener"
Maybe the IP was good, there is a listener at myhost, but it is listening on a different port. "ORA-12560: TNS:protocol adapter error"
Maybe the IP was good, there is a listener at myhost, it is listening on the specified port, but doesn't know about SERVICE_NAME = curley. "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor"
================ -
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-43cc3b44I 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. -
How to automate accept client of the server side?
Hi.....
I am a beginner of using J2ME to developing my final year project. I have some problem of using bluetooth packet. I can't accept again the client message when the server accepted before. Any one can solve my problem? How can I using the loop or timer to accept the client message without using acceptAndOpen() packet? Thank a lot.....
The sample code is here:
- Server side
public class BluetoothServer implements Runnable {
private GameMIDlet gameMIDlet;
private HandleSetting setting;
private HandleScore score;
private ScreenGame screenGame;
private int playerMethod;
//private GUIGameServer guiGameServer;
StreamConnectionNotifier notifier;
StreamConnection conn;
LocalDevice localDevice;
ServiceRecord serviceRecord;
InputStream input;
OutputStream output;
private boolean isInit;
private boolean isReady;
private static String serverUrl = "btspp://localhost:" + ScreenMultiPlay.SHARE_UUID + ";name=GameServer;authorize=true";
public BluetoothServer(GameMIDlet gameMIDlet,HandleSetting setting, HandleScore score, int playerMethod) {
this.gameMIDlet = gameMIDlet;
this.setting = setting;
this.score = score;
this.playerMethod = playerMethod;
isReady = false;
isInit = false;
Thread accepterThread = new Thread(this);
accepterThread.start();
public void run() {
if (!isInit) {
// Initialization is done in the thread to avoid dead lock 'isInit' ensures it is done once only
try {
conn = null;
localDevice = LocalDevice.getLocalDevice();
localDevice.setDiscoverable( DiscoveryAgent.GIAC );
notifier = (StreamConnectionNotifier)Connector.open(serverUrl);
} catch (BluetoothStateException e) {
System.err.println( "BluetoothStateException: " + e.getMessage() );
} catch (IOException e) {
System.err.println( "IOException: " + e.getMessage() );
isInit=true;
System.out.println( "Starting Echo Server" );
try {
System.out.println("\n\nServer Running...");
isReady=true;
if (isReady) {
try {
screenGame = new ScreenGame(this.gameMIDlet,this.setting,this.score,playerMethod);
screenGame.start();
Display.getDisplay(gameMIDlet).setCurrent(screenGame);
} catch(Exception e) {
gameMIDlet.showErrorMsg(null);
// Pauses thread until Transmission occurs
conn = notifier.acceptAndOpen();
// Read Data Transmission
String msg = ScreenMultiPlay.readData(conn);
System.out.println("Received Message from Client: " + msg);
// Send Back a Message
msg = "Hello Back from Server";
output = conn.openOutputStream();
output.write(msg.length()); // length is 1 byte
output.write(msg.getBytes());
output.close();
} catch (Exception ex) {
System.err.println("Bluetooth Server Running Error: " + ex);
public void destroy() {
//isClosed = true;
// finilize notifier work
if (notifier != null) {
try {
notifier.close();
isInit=false;
} catch (IOException e) {} // ignore
// wait for acceptor thread is done
/*try {
accepterThread.join();
} catch (InterruptedException e) {} // ignore*/
-Client side
class BluetoothClient implements DiscoveryListener {
private GameMIDlet gameMIDlet;
private HandleSetting setting;
private HandleScore score;
private ScreenGame screenGame;
private int playerMethod;
private DiscoveryAgent discoveryAgent;
private RemoteDevice[] remoteDevices;
private UUID[] uuidSet;
private String serviceUrl;
public BluetoothClient(GameMIDlet gameMIDlet,HandleSetting setting, HandleScore score, int playerMethod) {
this.gameMIDlet = gameMIDlet;
this.setting = setting;
this.score = score;
this.playerMethod = playerMethod;
try {
LocalDevice localDevice = LocalDevice.getLocalDevice();
discoveryAgent = localDevice.getDiscoveryAgent();
discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this);
//-----go to deviceDiscovered()-----------------
} catch (Exception e) {
System.out.println(e);
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
try {
// Get Device Info
System.out.println("Device Discovered");
System.out.println("Major Device Class: " + cod.getMajorDeviceClass() + " Minor Device Class: " + cod.getMinorDeviceClass());
System.out.println("Bluetooth Address: " + btDevice.getBluetoothAddress());
System.out.println("Bluetooth Friendly Name: " + btDevice.getFriendlyName(true));
// Search for Services
uuidSet = new UUID[1];
uuidSet[0] = ScreenMultiPlay.SHARE_UUID;
int searchID = discoveryAgent.searchServices(null,uuidSet,btDevice,this);
//-------------go to inquiryCompleted()----------------------
} catch (Exception e) {
System.out.println("Device Discovered Error: " + e);
public void inquiryCompleted(int discType) {
System.out.println("InquiryCompleted");
//---------------go to servicesDiscovered()------------------------
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
System.out.println("ServicesDiscovered");
// in this example there is only one service
for(int i=0;i<servRecord.length;i++) {
serviceUrl = servRecord.getConnectionURL(0,false);
//---------------go to serviceSearchCompleted()--------------------
public void serviceSearchCompleted(int transID, int responseCode) {
if(responseCode == SERVICE_SEARCH_ERROR)
System.out.println("SERVICE_SEARCH_ERROR\n");
if(responseCode == SERVICE_SEARCH_COMPLETED) {
System.out.println("SERVICE_SEARCH_COMPLETED\n");
System.out.println("Service URL: " + serviceUrl);
StreamConnection conn = null;
try {
String msg = "Say Hello World";
conn = (StreamConnection)Connector.open(serviceUrl);
OutputStream output = conn.openOutputStream();
output.write(msg.length());
output.write(msg.getBytes());
output.close();
System.out.println(ScreenMultiPlay.readData(conn));
} catch (Exception ex) {
System.out.println(ex);
} finally {
try {
conn.close();
} catch (IOException ioe) {
System.out.println("Error Closing connection " + ioe);
if(responseCode == SERVICE_SEARCH_TERMINATED)
System.out.println("SERVICE_SEARCH_TERMINATED\n");
if(responseCode == SERVICE_SEARCH_NO_RECORDS)
System.out.println("SERVICE_SEARCH_NO_RECORDS\n");
if(responseCode == SERVICE_SEARCH_DEVICE_NOT_REACHABLE)
System.out.println("SERVICE_SEARCH_DEVICE_NOT_REACHABLE\n");This question isn't logical at all. You don't execute javascript on the server. But if you want to waste time on it. .. look at Rhino http://www.mozilla.org/rhino/
Best of luck... -
Monitoring an applet on a thin client from the server
Hello all,
I'm not even sure if this is possible or not, but here is what I would like to do.
I want to be able to monitor an applet running on a remote thin client device from the central server to determine if there have been any problems (exceptions, device failures, etc).
I'll be using java 1.5.0. If you require more info please let me know.
Thanks,But would anyone know if there is a similar method for applets?
What makes you think you can't use that technique in an applet? Use that, and contact the server when there's an uncaught exception.
You'll probably want to report a number of caught exceptions too (unless you're really bad at handling exceptions).
Best bet is to use a utility class on your applet with a method like "logError(Throwable t, String message)" which will send the details up to the server, maybe output to the console, maybe even pop up a dialog. If you did this via an interface you could plug in different implementations and compound them if required. -
How is the dsame client find the server ?
Hi,
manager = SSOTokenManager.getInstance();
token = Manager.createSSOToken(new AuthPrincipal("uid=amAdmin,ou=administrators,ou=topologymanagement,o=netscaperoot"), "abcdefg123");
amConn = new AMStoreConnection(Token);
I have above code fragment in a standalone Java application. The Java client could not find the server. I could not use Httprequest to get the server infomation. I tried token.setproperty("hostname",dsame. wad.com.au);
tolen.setproperty("port",58080);
But this doesn't help.
Thanks in advance!!
RaviPlease ignore the syntex errors in above code.
Thanks,
Ravi
Maybe you are looking for
-
How to know if a scrollbar is been drawn if the JScrollPane is not visible.
I have a JTabbedPane with one JPanel in each tab. Each of these panels contains one JLabel with a JTextBox on the top and under it the rest is filled with a JScrollPane containing a JTable. I am using a GridBagLayout. Now, the requirement is that the
-
Run time improvement strategies in Oracle 9i PL/SQL
Hi, I have a PL/SQL program that does some calculations and updates few tables. The program now needs to scale to support some terabytes of data. Also I have a constraint on the run time of the program (around 30 mins). The Logic for the program supp
-
hi IDE: Netbeans7.1 Server:Weblogic 10.0 JSF:2.1 JPA:toplink essential JPA 1.0 When i`m inserting JPA in my JSF project following error Shown, Any one have Idea abt it? init: deps-module-jar: deps-ear-jar: deps-jar: library-inclusion-in-archive: libr
-
Can't See 9600M Information in System Profiler
Hello, I have a 15" 2.53 MBP bought refurbished in 2009. I was looking through my System Profiler today and realized I can only see the 9400M in the Graphics/Display section, the 9600 isn't anywhere to be found. I have the option to switch to "Perfor
-
Is polish language supported on 4g's ipod? If yes, where can I get it, and how does it install? If no, it is possible to make update software, which will include polish language.