How to recognize broken socket in client
How can I trap a broken socket connection in my client program?
This is what I tried
---Client connects to server successfully
---client sends message to server
try {
output = new PrintWriter(socket.getOutputStream(),true);
output.println("hello world");
} catch (IOException ) {}
In the meantime if the server has exited, I do not see any IOException in my client side when it tries to do a output.println(....)
Here is an extract from the server side code.
while(true) {
Socket socket = server_socket.accept();
System.out.println("New connection accepted " +
socket.getInetAddress() +
":" + socket.getPort());
input = new BufferedReader(new InputStreamReader(socket.getInput
Stream()));
System.exit(1);
}
How can I trap a broken socket connection in my client program?I do not know the answer to your question. But I see variations on this question posted frequently. You might trying searching the forums (perhaps using the Advanced Search). Try some of these keywords, socket detect alive closed connected
I would suggest you collect quite a few links and read through them all. Some people know more than other people.
Here are some links to get you started
http://forum.java.sun.com/thread.jsp?forum=31&thread=309853
http://forum.java.sun.com/thread.jsp?forum=31&thread=305274
http://forum.java.sun.com/thread.jsp?forum=31&thread=303815
http://forum.java.sun.com/thread.jsp?forum=11&thread=16436
http://forum.java.sun.com/thread.jsp?forum=31&thread=272241
http://forum.java.sun.com/thread.jsp?forum=31&thread=285043
Similar Messages
-
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 use multithead with socket
How use multithead with socket
I need do a client and server program that accept multitherad issue
Thanks who can help meyou'd have to do something like this:
(this is all assuming you want to read Strings from the socket. setSoTimeout works for any read() call to the InputStream associated with the Socket)
ServerSocket ss = new ServerSocket(myPort);
Socket s = ss.accept();
s.setSoTimeout(5*60*1000); // 5 mins * 60 secs * 1000ms
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
boolean running = true;
while(running)
try
String readIn = in.readLine();
// do whatever you want with the data read
catch(SocketTimeoutException)
running = false;
Now. That's what I think needs to be done. I don't have Java on the machine I'm currently on, so I can't test/verify it, but it goes something like that.
Good luck,
Radish21 -
Hi Everyone,
I know this question has been raised before, but it is still an issue.
I have a java application that communicates with another non java application using sockets. I keep the socket open all the time unless it gets closed by some firewall or network error resulting in a broken socket. In such a case the java system cannot detect this. I only discover this when an exception is thrown which is unsightly.
How can I detect a broken socket?
This is a serious flaw in java and HTTPClient does not address it either.
Any ideas? Thanks in advance
Lukajava.net.Socket.setKeepAlive(boolean on)
http://www.unixguide.net/network/socketfaq/4.7.shtml
BIJ001
Please include jschell's warning about the SO_KEEPALIVE option when you recommend its use.
It IS NOT supported by most TCP/IP stacks. It can be configured on systems that do support it, for example on Solaris the ndd command can be used to set the variable tcp_keepalive_interval, its defualt is 2 hours.
lteklic
This is not a Java problem. This is a TCP problem that you will encounter on any socket implementation. Even if you use setKeepAlive you will still get an IOException when the socket is reset. Your best bet for a portable solution is to build a keep alive transmission into your protocol, or to close sockets that have been idle for a prolonged period of time. -
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. -
How to develope a XML-RPC client with PL/SQL
Anyone know how to develop a XML-RPC client with PL/SQL?
I've oracle 8i.
Have you some example of code?
Thanks
PaoloSo, you actually want to create the physical directory using JAVA?
Then see:
http://www.oracle-base.com/articles/8i/shell-commands-from-plsql.php -
How can I allow a user (client) to choose a local image file (on his hard d
How can I allow a user (client) to choose a local image file (on his hard drive) and modify it using an applet from his browser ? I am trying to develop a web page that enables the user to choose an Image file, manipulate the image using a java applet, and display the results.
Using Java�s �JFileChooser� does not work when called from a browser, probably due to security privileges issues. On the other hand, I can choose and upload any file using a JavaScript form:
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="process.asp">
<INPUT TYPE=FILE NAME="file1"><BR>
�
It seems that I can choose an image file with a Java script form and process an image with an applet. How can I choose a file AND process it locally ?
(I do not wish to upload the file to the server using JavaScript form and then back to the client�s applet for processing since it will be a tremendous waste of resources).
Will appreciate any solution.
Thanks !
( my email is: [email protected] )"Using Java�s �JFileChooser� does not work when called from a browser, probably due to security privileges issues. "
You can do this if you sign the applet... -
How to put image file on client machine through JBOSS
I need to imlement the functionality like google map on website, where my server is JBOSS
server. We used the newest technology SVG(scalable vector graphics) which doesn't loose the
image quaility on increasing the size of the image.
we are doing backend processing of the image and throwing the png images on the client.
machine. I already written a program which can be used at the time of zooming and panning
of the image and can throw the image but that is all PC based. but when I am implementing
on the server it is giving error because code is not getting any output directory to save
the image on sever.
Please tell me if that can be happen through caching or how can I save image on
client machine without user authenication and can retrieve on the web page. so that my
server doesn't have extra load.hi jagdish,
Check this thread. discussed uploading file step by step
Re: How to upload and search a document in KM
Regards,
Ganesh N -
HOW TO GET INFORMATION ABOUT THE CLIENT MACHINE AT DATABASE LEVEL
HOW TO GET INFORMATION ABOUT THE CLIENT MACHINE AT DATABASE LEVEL USING 10g Database and 10g Application Server
we have developed an application using oracle forms 10g with
oracle database 10g and Application server 10g
Application uses a single Oracle User name to connect to database
where as at Application level there are different users (these are not database users)
Now how can we get the information about the user/his machine etc. at database level. earlier in 6i/8i we use to get by using
USERENV('TERMINAL')
we had written a triggers on tables on Insert/Update where we used to update a database field Last user terminal with USERENV('TERMINAL')
but not this information is comming to be the machine name of application server where as we wish this to be the machine name of Client. Any Way outs
thanks
Chaand Kackriahi, you can use the sys_context function, like this:
select sys_context('userenv','current_user'),
sys_context('userenv','os_user'),
sys_context('userenv','host'),
sys_context('userenv','ip_address'),
sys_context('userenv','instance'),
sys_context('userenv','sessionid'),
sys_context('userenv','terminal')
from dual;
Is this what you 're looking for? -
How do I bind 10.4 clients to a 10.5 server?
I've been given the task of cleaning up a Mac network that has 15 iMacs....some running 10.4 and some 10.5.
2 issues
1 - as a test I created an account called MacA on the server, and there are only 6 other accounts listed in the server....BUT, some of the iMacs that have complete access to the server, are not listed in the accounts on the server. So I can go to some of the 15 iMacs, and login as JohnD and have complete access, but JohnD is not on the list of server accounts. this seems to just be a roaming client in the network, how do I delete these roaming clients?
2 - When I am on a Machine that is running 10.5, I go to SYST PREF>ACCTS>LOGIN OPTIONS> and then a NETWORK ACCT SERVER(JOIN) option shows.....when I CLICK on this, I can type in the name of the central Mac server, and VOILA, I can then log in as the user MacA that I created on the central server
HOWEVER
on a machine running 10.4, when clicking on SYST PREF>ACCTS>LOGIN OPTIONS....there is no NETWORK ACCT SERVER(JOIN) option.....
what am I doing wrong.....and how exactly do I go about JUST creating accounts/users on the central server, and when these client machines get the login popup, ONLY the accounts that I've created can login to the server?Hi
+"1- I create a user on the 10.5 server in accounts"+
From what you've been saying of what it is you think you want to do, this is not the place to be creating network accounts. Assuming I've understood what it is you want. Launch WorkGroup Manager. Select the LDAPv3 node. Create users you wish to have desired network homes. Assign passwords or define a Password Policy. In the Homes tab select the share point you've already shared and defined as an auto-mount for networked homes. Click Create Home Now. Click Save. That's basically it. Repeat the process for however many users you have or want. Alternatively create all the users you want first in one go. Select them all (apart from diradmin) and click Create Home now followed by Save.
All of this assumes:
(a) DNS is correctly configured
(b) Users are defined in the correct directory
(c) Server is correctly configured to allow LDAP accounts
(d) Workstations are using the relevant DNS Server
These are just to begin with.
+"b - allow network users to login to this computer (it is here that I see the users that I've created on the server, and put them on the list to allow to login)"+
IMO there truly is no need to do this at the stage you're at now. Get the basics figured out correctly. Above all just get it working. If it's a requirement for your environment to control and/or manage - later on - which network based accounts are allowed to login on designated workstations look at that option then.
NB: Local accounts will always take precedence over networked accounts if named exactly the same.
Tony -
How to recognize if application is installed using "Install application on remote desktop..." option in Control Panel in Windows Server 2008 R2?
Basically, as administrator, I can't say if the user installed application using "Install application on remote desktop..." in Control Panel or he just installed it by clicking the .msi executable. I can't find anything that makes any difference.
I could not find anything in the registry. I am quite confused.
Thanks,
Aleksandar9Hi,
Thank you for your posting in Windows Server Forum.
Please make sure that you are using category view of control panel-programs to check the application. And in addition to “install application on Remote Desktop server” user can also use command line also.
change user /install
change user /execute
change user /query
“The first time you run the application, it searches the home directory for its .ini files. If the .ini files are not found in the home directory, but are found in the system directory, Terminal Services copies the .ini files to the home directory, ensuring
that each user has a unique copy of the application .ini files. Each user should have a unique copy of the .ini files for an application. This prevents instances where different users might have incompatible application configurations.” (Quoted formthis
article).
Hope it helps!
Thanks,
Dharmesh -
How do I get list of client IP Addresses using new Airport Utility v6.3?
I have purchased and Airport Time Capsule 3TB (newest model). Previous models were still compatible with Airport Utility 5.6 and I could use "manual" mode to get a list of client IP addresses attached to the device. The new Airport Time Capsule is only compatible with Airport Utility 6.3 and I cannot figure out how to get a list of client IP addresses with this new model. Does anyone know how to do this?
Try a ping broadcast - for example if your network were 192.168.1.xxx (netmask of 255.255.255.0) try this from a Termnal.app window (located in /Applications/Utilities):
ping 192.168.1.255
If you have a different type netmask, you need to put 255's where the 0's are in your netmask.
Everyone on the local network (the 192.168.1.xxx network) should reply that is up and running unless you have them setup to not respond to pings (the WAN port on your TC should not reply cause it's in a different network) and you have your list of clients on the network. If you setup the TC to dedicate a range of addresses for WiFi clients you can even identify which of them are wired and which are wireless.
good luck. -
How to use log4net with C# clients
Hi,
Can anybody please give an example of how to use log4net with C# clients? Foe java clients you can use the
<logging-config>
<destination>log4j</destination>
How do we use it with C# clients? Any example will be appreciated.
Thanks.
-aliAli,
The following is an example on how to define a custom logger (including log4net) in tangosol-coherence-override.xml for coherence .NET client; you need Coherence .NET client 3.7.1 patch 1.
<coherence xmlns="http://schemas.tangosol.com/coherence">
<logging-config>
<destination>common-logger</destination>
<logger-name>log4net</logger-name>
<severity-level>9</severity-level>
<message-format>(thread={thread}): {text}</message-format>
<character-limit>8192</character-limit>
</logging-config>
</coherence>
You also need to configure log4net in app.config. Please see the following web page for more information:
http://netcommon.sourceforge.net/docs/2.0.0/reference/html/ch01.html
-Luk -
How do I make a RMI client running in Bea find a remote, non Bea, RMI server?
On my stand alone test system I run a RMI server in one JVM,
registry.exe and a RMI client in its own JVM. The client uses
java.rmi.Naming.lookup() to find the RMI server, and this works fine.
If I run the same RMI client class within Bea the naming lookup fails! I
guess this is due to Bea using it own RMI registry rather than the
registry.exe I started separately(?)
QUESTION: How do I make a RMI client running in Bea find a remote,
non-Bea, RMI server?
Of course, in the final environment the server will run on a system
remote from Bea.
The RMI client calls are done from a servlet, not from a EJB.
The doumentation about using RMI with Bea is focused on running the RMI
server within Bea. This might be the "normal" thing to do, but in our
case Bea is the client, not the server. Do I still need to use
weblogic.rmi.*....? If so, where?
Grateful for any tip.
Göran HagnellOn my stand alone test system I run a RMI server in one JVM,
registry.exe and a RMI client in its own JVM. The client uses
java.rmi.Naming.lookup() to find the RMI server, and this works fine.
If I run the same RMI client class within Bea the naming lookup fails! I
guess this is due to Bea using it own RMI registry rather than the
registry.exe I started separately(?)
QUESTION: How do I make a RMI client running in Bea find a remote,
non-Bea, RMI server?
Of course, in the final environment the server will run on a system
remote from Bea.
The RMI client calls are done from a servlet, not from a EJB.
The doumentation about using RMI with Bea is focused on running the RMI
server within Bea. This might be the "normal" thing to do, but in our
case Bea is the client, not the server. Do I still need to use
weblogic.rmi.*....? If so, where?
Grateful for any tip.
Göran Hagnell -
How to recognize the linked text boxes in In Design
How to recognize the linked text boxes in In Design? I mean is there any indication, where I will come to know so an so tex boxes are linked together?
Thanks in advance.HI Peter,
well In Quark Express as as wrote earlier, that you can see other text frames highlighted immediately, after you select any of the text frame among the threaded text frames, say there are 5 text frames which are threaded together, even if I click on 2 nd or say 4th text frame, it shows me all the text frames highlighted which are threaded together, so If I am working in a catalog which has multiple pages, it's easy for me to see which text frames are threaded together, as if you make any text changes, say add or delete text in a text frame, the other text frames get affected by that. I mean text shifts accordingly, it's easy to track in Quark which text frames will get affected if I change something in a threaded frame.
Anyways, it seems this option is not available in In Design. That's fine. I am not in preview or Overprint previed mode.
Thanks for your help.
Maybe you are looking for
-
Cant pass file from a dir to fileinputstream()
hi ! i am stuck here ..please help. I have an application that creates a dir called temp in home directory . and and a file which is named in following format. for example 080718002220.txt i.e. systemdate.ext type . Since this files are created in re
-
My daughters ipad mini has locked her out.
My daughters ipad mini has locked her out. She had set a password for her screen lock then failed to put it in correctly and now the ipad has locked. The screen says to connect to iTunes but when I do her ipad does not appear I the list.
-
Any idea?
-
My ipad 5 does not start without i reboot
Mon ipad ne démarre pas lorsque j'appuie sur le bouton principal. Je dois le redémarrer en appuyant sur le bouton marche/arrêt et le bouton principal. Avez-vous une solution ? Have you a solution ?
-
HT4623 is the ipod touch 4th generation compatible with ios7
My son has an iPod touch 4th gen. and was trying to update it but it says at version 6.1.5 that it is at the latest version. Is the 4th gen ipod touch able to update to verion 7 of ios?