J2EE Connection Architecture - Client Socket implementation
I have a requirement to use a Socket connect to a quote vendor and ask for a quote(s) then receieve the response. The request looks like SQL except for the stream level info like lengths etc.. I wonder if anyone has implemented something like this as a JAC (J2C) application and could provide a sample? In a managed JAC environment the Application Server would provide a pooling mechanism; thus, the connection would remain active and be able to service many requests..
This may be a forum bug, but your post has appeared in the JBI forum, not the Connector forum. I suspect your chances of getting an answer to your query would be better in the appropriate Connector forum.
Similar Messages
-
Does the socket implementation suport only 2 simultaneous connections?
Hi all,
I implemented this server the traditional way:
public void run() {
while(state.isRunning()) {
try {
System.out.println("listening...");
sourceSock = ssock.accept();
System.out.println("new incoming connection");
sourceSock.setSoTimeout(config.getHttpTimeout());
new Thread(new ProxyHttpConnectionWorker(sourceSock, config)).start();
} catch (IOException _ex) {
config.out.trace(_ex.getMessage());
}It seems ok to me. I implemented it several times in a lot of situations.
However, this time I noted that after two simultaneous socket connections are opened (via accept()), all other connections I try to make from a client are blocking until one of the first two sockets close().
I mean, it seems to be blocking the incoming connections in the accept() method, because the string "listening..." was printed, but the string "new incoming connection" is only printed when one of the two initial sockets close()
Why is this happening? Is this correct?
I implemented it with J2SE 1.3.1 in a windows NT 4 workstation machine.
Is this an Operating System problem? A TCP/IP problem? Is the problem in the java socket implementation? Is there any flaw in my code?
Thank you all in advance,
Filipe FedaltoHi, Chuck
It could also be the case.
Actually, I am implementing a proxy server. All the major work is done and were it not this accept() problem it would be functioning very well.
The server is running in my machine and I am testing it by issuing 4 simultaneous HTTP requests from Internet Explorer 5.5 from my own machine itself. So, you see, this could be the problem, according to what you've just said.
I try to open the 4 browser connections simultaneously, but the servers' accept() method only seems to receive 2 of them at a time.
What do you think about it?
Just in case, I will try and test it using Netscape. Let's see if the number of simultaneous connections change...
Notwithstanding, why do the browsers limit the number of concurrent connections? I might think that this is because it is better to open a single page or two faster than trying to open 5 or 6 pages slowly... is this the point?
Thank you very much!
Filipe Fedalto -
Direct Connection between clients using sockets
Hi, I'm a new user and i have a problem with sockets:
The question is how can i directly connect two users that are already connected to a server in other machine???
I mean
user1 is connected to server
user2 is connected to server
user1 tries to communicate with user1 but don't want to use the server, and the server only provides the client1's ip
I first thought to do this:
user2 asks to server for the info of a client1-server waiting for connections, and i think it could work fine, but only if the ports are not closed by firewall, because client-server will be running in a transparent mode for user and user may not know anything about servers, sockets, ports, etc. the user only will work with a gui or something else and that's all
Does anybody know what can i do to make this possible???
PD
Sorry for my bad EnglishIt can be implemented like you said. Make one of the clients open a serversocket and pass the ip and port number through the server to the other client with information on where to connect.
If you're going to use direct connection between clients a lot then I would recommend that every client open a default serversocket at startup and register that information with the server and then every other client can ask the server for the ip and port to whatever client they wish to open a direct connection to.
Be aware that clients often are behind NATs and firewalls, so if need to deal with those issues you got to use hole punching (http://en.wikipedia.org/wiki/hole_punching) - pref on a known port like 80 - and to deal with the less frequently used application firewalls you can use http encapsulation in addition. -
Java Chat (Server, Client Socket Connection)
Assignment:
The assignment is to deliver two source codes that can run a Server (1) and Clients (2) in order to create a simpel chat program. The server has to wait and check an IP (localhost) + Port, and the client has to connect to that port and create a socket connection. The only thing that should be done is create a new socket connection for each client... and when a client sends a message, the message should be delivered to all clients connected to the server.
Problem...
However I can read an edit Java, it's difficult for me to write it. I allready found many turturials about socket connections on the internet, and tried to edit those, but they don't really do what I want unless I really write new shit. Is there a way you guys can help me with this, or that you find a really good website that fits my question?According to me ,
take string variable 'str'
Take some class ,I think u already taken.....
Scoket scoket = new Socket(IP,port);
OutputStream out;
IInputStream in;
in = socket.getInputStream();
out = socket.getOutputStream();
If sends the msg then use
out.writeObject(str);
This line sends data to the other user
msg resivce from client then use
str = in.readInput();
& this str set to the any objects out put .
Such as TextField.setText(str);
//Server.class
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Server extends JFrame
private JTextField enterdField;
private JTextArea displayArea;
private ObjectOutputStream output;
private ObjectInputStream input;
private ServerSocket server;
private Socket connection;
private int counter=1;
public Server()
super("Server");
enterdField = new JTextField();
enterdField.setEditable(false);
enterdField.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
sendData(event.getActionCommand());
//System.out.println(event.getActionCommand());
enterdField.setText("");
add(enterdField,BorderLayout.NORTH);
displayArea = new JTextArea();
add(new JScrollPane(displayArea),BorderLayout.CENTER);
setSize(300,150);
setVisible(true);
public void runServer()
try
server = new ServerSocket(12345,100);
while(true)
try
waitForConnection();
getStreams();
processConnection();
catch(EOFException eofexception)
displayMessage("\nServer terminated connection");
finally
closeConnection();
counter++;
catch(IOException ioException)
ioException.printStackTrace();
private void waitForConnection() throws IOException
displayMessage("Waiting for connection");
connection = server.accept();
//System.out.println(server.accept());
System.out.println(connection.getInetAddress());//Server Address and Hostname.
displayMessage("Connection"+counter +"received from :"+connection.getInetAddress().getHostName());
private void getStreams() throws IOException
System.out.println("Start getStream");
output = new ObjectOutputStream(connection.getOutputStream());
output.flush();
input = new ObjectInputStream(connection.getInputStream());
displayMessage("\nGot I/O stream\n");
private void processConnection() throws IOException //Read data from Client for Server.
String message="Connection sucessful To Client";
sendData(message);
int i=0;
setTextFieldEditable(true);
do
try
message =(String) input.readObject();//For Client
System.out.println("Input from :"+message);//From Client
displayMessage("\n" + message);
System.out.println("\n" + i++);
catch(ClassNotFoundException classnotfoundexception)
displayMessage("\nUnknown object type recived");
while(!message.equals("CLIENT>>>TERMINATE"));
private void closeConnection()
displayMessage("\nTeminating connection");
setTextFieldEditable(false);
try
output.close();
input.close();
connection.close();
catch(IOException ioException)
ioException.printStackTrace();
private void sendData(String message)//Write data to the Client from the Server.
try
output.writeObject("SERVER>>>"+message);//For Client side.
System.out.println(message);
output.flush();
displayMessage("\nSERVER>>>"+message);//On server side.
catch(IOException ioException)
displayMessage("\nError writing object");
private void displayMessage(final String messageToDisplay)
SwingUtilities.invokeLater(
new Runnable()
public void run()
displayArea.append(messageToDisplay);
private void setTextFieldEditable(final boolean editable)
SwingUtilities.invokeLater(
new Runnable()
public void run()
enterdField.setEditable(editable);
public static void main(String q[])
Server app = new Server();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.runServer();
//Client.class
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Client extends JFrame
private JTextField enterField;
private JTextArea displayArea;
private ObjectOutputStream output;
private ObjectInputStream input;
private String message="";
private String chatServer;
private Socket client;
public Client (String host)
super("Client");
chatServer=host;
enterField = new JTextField();
enterField.setEditable(false);
enterField.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
sendData(event.getActionCommand());
enterField.setText("");
add(enterField,BorderLayout.NORTH);
displayArea = new JTextArea();
add(new JScrollPane(displayArea),BorderLayout.CENTER);
setSize(300,150);
setVisible(true);
public void runclient()
try
connectToServer();
getStreams();
processConnection();
catch(EOFException eofException)
displayMessage("\nClient treminated connection");
catch(IOException ioException)
ioException.printStackTrace();
finally
closeConnection();
private void connectToServer() throws IOException
displayMessage("Attempting connection\n");
client = new Socket(InetAddress.getByName(chatServer),12345);
displayMessage("Connect to:"+client.getInetAddress().getHostName());
private void getStreams() throws IOException
output = new ObjectOutputStream(client.getOutputStream());
output.flush();
input = new ObjectInputStream(client.getInputStream());
//Thread t = new Thread(this,"Thread");
//t.start();
displayMessage("\nGot I/O stream\n");
private void processConnection( ) throws IOException
setTextFieldEditable(true);
do
try
message=(String)input.readObject();
displayMessage("\n"+message);
catch(ClassNotFoundException classnotfoundexception)
displayMessage("\nUnknown object type received");
while(!message.equals("SERVER>>>TERMINATE"));
private void closeConnection()
displayMessage("\n Closing connection");
setTextFieldEditable(false);
try
output.close();
input.close();
client.close();
catch(IOException ioException)
ioException.printStackTrace();
private void sendData(String message)
try
output.writeObject("CLIENT>>>"+message);
//System.out.println(message);
output.flush();
displayMessage("\nCLIENT>>>"+message);
catch(IOException ioException)
displayArea.append("\n Error writing object");
private void displayMessage(final String MessageToDisplay)
SwingUtilities.invokeLater(
new Runnable()
public void run()
displayArea.append(MessageToDisplay);
private void setTextFieldEditable(final boolean editable)
SwingUtilities.invokeLater(
new Runnable()
public void run()
enterField.setEditable(editable);
public static void main(String q[])
Client app;
if(q.length==0)
app = new Client("127.0.0.1");
else
app = new Client(q[0]);
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.runclient();
Use this example .....
Give me reply.My method is correct or not
All the best -
Server/Client Socket Connection
Hi, I am trying to program a simple server/client socket connection program, the main function is to send and receive objects between them. I somehow went wrong and the connection between them keeps terminating right after establishing connection. Is there anything I can do to resolve this?
This is gonnna be kinda long post.. sorry. These are the code that starts and ends the socket connection. I'm kinda desperate for this to work.. so thanks in advance.
appinterface.java:
//Set up server to receive communications; process connections. 1x.
public void runServer () {
try {
//Create a ServerSocket
server = new ServerSocket(12345, 100);
try {
waitForSockConnection(); //Wait for a connection.
getSockStreams(); //Get input & output streams.
establishDbConnection(); //Open up connection to DB.
finally {
closeSockConnection(); //Close connection.
//Process problems with I/O
catch(IOException ioException) {
displayMessage("I/O Error: " + ioException);
runServer();
//Wait for connection to arrive, then display connection info
private void waitForSockConnection() throws IOException {
displayMessage("Waiting for connection");
connection = server.accept(); //Allow server to accept connection.
displayMessage("Connection received from: " + connection.getInetAddress().getHostName());
//Get streams to send and receive data.
private void getSockStreams() throws IOException {
//Set up output streams for objects
ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
output.flush(); //Flush output buffer to send header information.
//Set up input stream for objects.
ObjectInputStream input = new ObjectInputStream(connection.getInputStream());
try {
classHolderServer holderObj = new classHolderServer();
holderObj = (classHolderServer)input.readObject();
processSockConnection(holderObj);
displayMessage("Got I/O Streams");
//Catch problems reading from client
catch (ClassNotFoundException classNotFoundException) {
displayMessage("Unknown object type received");
//Process connection with client.
private void processSockConnection(classHolderServer holderObj) throws IOException {
//sendMessage("Connection Successful");
//True is query, and false is auth.
if(holderObj.type1==true)
processDbStatement(holderObj.type2, holderObj.sqlquery);
else {
authCheck(holderObj.userName, holderObj.passWord);
if(!authCheck)
closeDbConnection();
//Send messages to client.
private void sendMessage(String message) {
// Send message to client
try {
ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
output.flush();
output.writeObject(message);
output.flush();
displayMessage("Message Sent:" + message);
catch (IOException ioException) {
displayMessage("\nError Sending Message: " + message);
//Send object to client
private void sendObject(Object holderObj) {
// Send object to client
try {
ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
output.writeObject(holderObj);
output.flush();
displayMessage("\nObject sent");
//Process problems sending object
catch (IOException ioException) {
displayMessage("\nError writing object");
//Close streams and socket.
private void closeSockConnection() {
displayMessage("Terminating connection");
try {
//output.close();
//input.close();
connection.close();
closeDbConnection();
this.userName = null;
this.passWord = null;
this.receiverId = 0;
this.authCheck = false;
catch (IOException ioException) {
displayMessage("I/O Error: " + ioException);
}Client:
private void runClient() {
//Connect to sever and process messages from server.
try{
connectToServer();
getStreams();
processConnection();
//Server closed connection.
catch(EOFException eofException) {
//displayMessage"Client Terminated Connection");
//Process problems communicating with server.
catch (IOException ioException) {
//displayMessage"Communication Problem");
finally {
closeConnection();
//Connect to server
private void connectToServer() throws IOException {
//displayMessage("Attempting connection\n");
//Create Socket to make connection to sever.
client = new Socket(InetAddress.getByName(chatServer), 12345);
//Display connection information
//displayMessage("Connected to: " + client.getInetAddress().getHostName());
//Get streams to send and receive data.
private void getStreams() throws IOException {
//Set up output stream for objects.
ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
output.flush(); //Flush outout buffer to send header information.
//Set up input stream for objects.
ObjectInputStream input = new ObjectInputStream(client.getInputStream());
//displayMessage("\nGot I/O streams\n");
//Close socket connection.
private void closeConnection() {
//displayMessage("\nClosing connection");
try {
ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
output.close();
ObjectInputStream input = new ObjectInputStream(client.getInputStream());
input.close();
client.close();
authCheck=false;
catch(IOException ioException) {
ioException.printStackTrace();
//Send data to server.
private void sendObject(classHolderClient queryObj) {
try {
output.writeObject(queryObj);
output.flush();
//displayMessage("Please wait..");
//Process problems sending object.
catch (IOException ioException) {
//displayMessage("\nError writing object");
//Process connection with server.
private void processConnection() throws IOException {
try{
classHolderClient holderObj = new classHolderClient();
holderObj = (classHolderClient)input.readObject();
if(holderObj.type2==2) {
this.authCheck=holderObj.authCheck;
this.userName=holderObj.userName;
this.passWord=holderObj.passWord;
catch(ClassNotFoundException classNotFoundException) {
//displayMessage(classNotFoundException);
}private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());Like this? But this will cause an error asking me to catch an exception:
C:\Documents and Settings\Moon\My Documents\Navi Projects\School\OOPJ Project\Prototype\GPS-Lite v2 Alpha Debugger\client.java:41: unreported exception java.io.IOException; must be caught or declared to be thrown
private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
^
C:\Documents and Settings\Moon\My Documents\Navi Projects\School\OOPJ Project\Prototype\GPS-Lite v2 Alpha Debugger\client.java:41: unreported exception java.io.IOException; must be caught or declared to be thrown
private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
^
2 errors -
Change the Client that J2EE connects to !
Hello Folks,
Our J2EE engine seems to be connected to Client 001(j2ee_admin user is actively occupying the sessions). But our active client is different.
How do we change the client that a j2ee engine connects to? We are in CRM5.0
ThanksHi Senthil,
If you want to just change the client then you have to go to the XCM of your application and follow the following link.
Components -> customer -> jco. here you will see the details of the client which you can change.
But if you want to keep the existing client and create another scenario which will connect to the diffrent client then you have to create a new jco, new Application configuration, new RFC connection. In CRM system you have to check the transaction SRMO.
<b>Allot points if my post helps!!</b>
Best regards,
Vikash. -
Connect mac client to mac printer share across subnets
I need to share printers from a Mac. I need to connect
Mac clients on different subnets to the Mac shared printers. I installed
a Mac mini, connected to printers via HP JetDirect Socket (port 9100), and
shared them. I was able to print from the Mac mini, and connect Mac
clients on the same subnet to the shared printers with Bonjour and print.
I moved the Mac mini to its intended location on another subnet. I
immediately learned that Bonjour does not publish services across
subnets. I could not find documentation on how to connect to a Mac shared
printer across subnets, but I did find some third party documentation (only some incomplete
documentation from Apple) on how to implement DNS-SD Service Discovery. I
enabled DNS-SD and was able to publish the printer shares across subnets, but I
was still unable to connect to the printer shares from a Mac client. I
found some third party documentation (none from Apple) on how to manually connect to a Mac
printer share by specifying the IP address of the server, specifying the CUPS
default IPP protocol, and the print queue name. I was unable to connect
to the shared printers. I receive ping replies from my Mac mini, and port
scan reveals that port 631 for IPP, CUPS default, is open. Printer
sharing is configured so everyone can print. I am able to connect to the Mac
mini with VNC Screen Sharing. I don’t see how this can be a network
issue.
Macs don’t seem to like to connect to our Windows
shared printers because of our PaperCut software, and connecting Mac clients to
Windows printer shares and authentication is beyond the average user,
exacerbated by Macs not behaving the same as Windows when bound to an Active
Directory domain.
I called Apple support, they escalated to Apple Enterprise
support. Apple Enterprise support said they couldn’t help me beyond a
single network with no subnets, but Apple Engineering might be able to solve
the problem for $695.
Why do I need to pay $695 to learn how to connect Mac
clients to Mac shared printers, something that should be easy and intuitive and
have documentation readily available? Windows printer sharing is easy and
intuitive and documentation is readily available, and services are published
across subnets without have to implement DNS-SD.Thank you for your reply. I followed the instructions in the sybaspot.com site and in some of the included references to set up DNS-SD. DNS-SD worked, but I couldn't connect the Mac client to the Mac shared printers.
I also found http://www.papercut.com/products/ng/manual/ch-mac-printing-10-8-9.html#ch-mac-pr inting-10-8-9-sharing-printers.
I expanded my search and found this: http://support.apple.com/kb/PH13940, last modified May 8, 2014. I started work on my project February 2014. Apple Support could have told me about this document.
PH13940 says: "The computers must be on the same local network as your Mac". Apple must not consider multiple subnets one network.
PH13940 says: "Printer sharing is for printers attached directly to your Mac. You don’t need to share network printers, because they are already shared on the network."
Apple must define "network printers" as any printer with a network interface. Microsoft defines network printers as printers shared by another computer. TCP/IP ports are local ports on a Windows computer, so TCP/IP connected printers are local printers that can be shared. Multiple users on a Mac all see the same connected printers. Multiple users on Windows all see the same local printers, but network printer connections can be different for each user.
Apple must not see any value in accounting for printing and assigning the cost to the user or department. We need to account for printing and cannot have any users bypassing the system by printing directly to printers. I have created Access Control lists on the printers to limit connections to the specific IP addresses of our print servers.
The documents about setting up DNS-SD and IPP connections must have assumed USB connected printers on a Mac. The odd thing is that I was able to share a network printer from the Mac mini when the client Mac was on the same subnet. Is PH13940 wrong?
I am Microsoft Certified Systems Engineer 1999 and Apple Certified Technical Coordinator 2013. -
How to detect client socket shutdowns in server socket
Hi,
Hoping to get some help with this. I am writing this program that implements a socket server that accepts a single client socket (from a third-party system). This server receives messages from another program and writes them to the client socket. It does not read anything back from the client. However, the client (which I have no control over) disconnects and reconnects to my server at random intervals. My issue is I cannot detect when the client has disconnected (normally or due to a network failure), hence am unable to accept a fresh connection from the client. Here's my code for the server.
ServerSocket serverSocket = null;
Socket clientSocket = null;
PrintWriter out = null;
BufferedReader in = null;
try{
if (serverSocket == null){
serverSocket = new ServerSocket(4511);
clientSocket = serverSocket.accept();
System.out.println("Accepted client request ... ");
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
System.out.println("Input / Output streams intialized ...");
while (true){
System.out.println("Is Client Socket Closed : " + clientSocket.isClosed());
System.out.println("Is Client Socket Connected : " + clientSocket.isConnected());
System.out.println("Is Client Socket Bound : " + clientSocket.isBound());
System.out.println("Is Client Socket Input Shutdown : " + clientSocket.isInputShutdown());
System.out.println("Is Client Socket Output Shutdown : " + clientSocket.isOutputShutdown());
System.out.println("Is Server Socket Bound : " + serverSocket.isBound());
System.out.println("Is Server Socket Closed : " + serverSocket.isClosed());
messageQueue = new MessageQueue(messageQueueDir+"/"+messageQueueFile);
//get Message from Queue Head (also removes it)
message = getQueueMessage(messageQueue);
//format and send to Third Party System
if (message != null){
out.println(formatMessage(message));
System.out.println("Sent to Client... ");
//sleep
System.out.println("Going to sleep 5 sec");
Thread.sleep(5000);
System.out.println("Wake up ...");
}catch(IOException ioe){
System.out.println("initSocketServer::IOException : " + ioe.getMessage());
}catch(Exception e){
System.out.println("initSocketServer::Exception : " + e.getMessage());
}I never use the client's inputstream to read, although I have declared it here. After the client is connected (it enters the while loop), it prints the following. These values stay the same even after the client disconnects.
Is Client Socket Closed : false
Is Client Socket Connected : true
Is Client Socket Bound : true
Is Client Socket Input Shutdown : false
Is Client Socket Output Shutdown : false
Is Server Socket Bound : true
Is Server Socket Closed : false
So, basically I am looking for a condition that detects that the client is no longer connected, so that I can bring serverSocket.accept() and in and out initializations within the while loop.
Appreciate much, thanks.Crossposted and answered.
-
Client socket binding to the same local/remote addresses
Hi all,
My Java program binds client socket to local address, local port, remote address and remote port. after that from different thread the program creates new socket and bind it to the same address as the first one. The question is: is there possibility that the second socket will be copy as the first one (with the same input/output streams) so that two threads in fact use the same TCP connection.
(Operating system is HP).
Thank you,
KateI have no need to store streams, my problem that each connection has it's own messages numbers(the application implements some protocol over TCP). so if a message number 1 was sent by some connection, and when different thread wants to send a message to the same remote host, it tries to pick up existing connection, but because of a bug creates the new one, which sends the message with number 1 also. And I see that there are situation whent the first thread receives response to the message number 1 althougth it was response to the message number 1 that the second thread has sent. So my question is if there is any possibility of this absurd situation?
-
How to dynamically connect Extend client to proxy server?
Hi,
Is it possible to do programmatically? My client should decide at run time to which node it will connect.
Thanks, Denis.Hi Denis,
Yes you can do this, you need to write an implementation of com.tangosol.net.AddressProvider which provides your client with the InetSocketAddress it should connect to. Your implementation of AddressProvider can then work out the end-point however it likes. You configure your remote-cache-scheme or remote-invocation-scheme to use the Addressprovider instead of putting in socket-address entries.
E.G. instead of this...
<tcp-initiator>
<remote-addresses>
<socket-address>
<address>192.456.789</address>
<port>10000</port>
</socket-address>
</remote-addresses>
</tcp-initiator>you do this...
<tcp-initiator>
<remote-addresses>
<address-provider>
<class-name>com.jk.MyAddressProvider<class-name>
<address-provider>
</remote-addresses>
</tcp-initiator>If you need to parameterise your AddressProvider you can add init-param entries to the config in the usual way.
JK -
BindException on client Socket?
When opening many client sockets under win2k, I am getting BindExceptions. This is without specifying any particular local port. The total number of simultaneous sockets open is only around 14 or 15, but thousands are being opened in a 1-2 minute period.
A BindException with a Socket(host, port) call seems counter-intuitive. I would assume that the OS is suppose to open it using an unused local port.
From my testing, it appears that the java.net.Socket() class only obtains local ports from the 1024-5000 port range. It seems to go through the range and wrap around a couple of times before the BindExceptions pop up.
Note that this appears to be the correct port range to allocate from based on various documentation, even though an equivalent program written in C does not seem to limit itself to that range (and does not exhibit the binding problem).
If I set the windows registry entry of MaxUserPort to a higher number, it takes longer for the BindException to occur since it has more ports to utilize. However, the problem doesn't go away.
Has anyone else seen this issue and come up with a solution? (Looping on the socket creation does not seem to be a very good long term solution)
Attached is a simple program which demonstrates the issue by making multiple HEAD requests to a webserver.
SockTest.java:
public class SockTest
public static void main(java.lang.String[] args)
int i;
for (i = 0; i < 14; i++)
SockTestThread thread = new SockTestThread();
thread.start();
}SockTestThread.java:
public class SockTestThread extends java.lang.Thread
private void runTransaction(java.lang.String hostname, int port)
try
java.net.Socket sock;
java.io.PrintStream out;
java.io.InputStream in;
java.lang.String request = "HEAD / HTTP/1.0\n\n";
byte[] response = new byte[4096];
sock = new java.net.Socket(hostname, port);
out = new java.io.PrintStream(sock.getOutputStream());
in = sock.getInputStream();
java.lang.System.out.println("Making request from local port " + sock.getLocalPort());
out.print(request);
out.flush();
in.read(response);
sock.close();
catch (java.lang.Exception exception)
java.lang.System.out.println(exception);
public void run()
int i;
for (i = 0; i < 1000; i++)
this.runTransaction("webserver", 80);
java.lang.System.out.println("Finished thread");There is only ever 14 sockets open at any one time. You will notice that the 1000 connections are done serially for each of the 14 threads. So, a socket is opened and closed (released) after each connection.
I'm not sure how a socket pool could be used/implemented here to help this. Also, up until the recent JDK1.4 release, there didn't appear to be a way to reuse a client socket. As far as I can tell, one can only create new sockets. Also, JDK 1.4 is not currently an option for me.
While this sample program just connects to a single web server to demonstrate the issue, the real application will be connecting to many different servers (web and others) and needs to be able to process the information and move on after each connection. -
Accepting connection from client
Hello,
I want to create java server which accepts connection from client once and then continuously waits for request sent by client. Something same as select() call in C
Something of kind
Server.java:
Socket socket = server.accept();
while(true)
// listen for request ,
// if request received , create new thread for processing
// return response
I don't want to accept connection again and again
Edited by: tryit on Aug 29, 2008 11:41 PMThanks for the reply.
But even in this library, an new thread is created which keeps on doing accept() in while(true) and after accepting connection , another thread is created to do the processing.
But i want that once the connection is established between server and client i.e once accept() is done then just using that socket rest of processing i.e read()/write() is done , no need for accept() in while(true)
I have something like this
SenderReciever.java
public class SenderAndReciever
private ServerSocket server;
private int port = 6000;
public SenderAndReciever()
try
server = new ServerSocket(port);
catch (IOException e)
e.printStackTrace();
public void handleConnection()
try
Socket socket = server.accept();
/* PROBLEM AREA */
/* This while loop results in infinite loop .
* if i move Socket socket = server.accept() inside while then it accepts one connection
* returns a response but then waits for another connection to be accepted
* But i want connection once accepted , use the same socket for rest all communications
while (true)
new ConnectionHandler(socket);
catch (IOException e)
e.printStackTrace();
public static void main(String[] args)
SenderAndReciever senderAndReciever = new SenderAndReciever();
senderAndReciever.handleConnection();
}ConnectionHandler.java:
class ConnectionHandler implements Runnable
private Socket socket;
public ConnectionHandler(Socket socket)
this.socket = socket;
Thread t = new Thread(this);
t.start();
public void run()
try
readData();
processData();
sendData();
catch (Exception e)
e.printStackTrace();
} -
HOw to connect FTP Client using flex
Hi Everyone,
i am new to flex, i am developing one flex application, some one give example of connecting ftp client using flex. i didnot found any examples.
thnxYou would need to communicate with your ftp server over a socket and implement the ftp protocol on your client. The project below aims to do this, but I have never used it:
http://maliboo.riaforge.org/
Why not download over http (and save yourself a lot of time)? -
Connecting Java client to SSL server with existing certificates
I am currently trying to connect my Java client to an existing server application
written in C++. I have been provided the needed certificates (root.pem, server.pem,
and client.pem). My code simply creates a SSLSocket and then attempts to read
from it. Something goes wrong during the handshake process and I get a SSLHandshakeException. The certificates have been added to the keystore
I am using, and I do not know any other action to take.
Here is the debug output:
setting up default SSLSocketFactory
use default SunJSSE impl class: com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl is loaded
keyStore is :
keyStore type is : jks
keyStore provider is :
init keystore
init keymanager of type SunX509
trustStore is: keystore.jks
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert:
Subject: [email protected], CN=Employee, OU=test, O=company-USA, L=City, ST=AL, C=US
Issuer: [email protected], CN=company Employee, OU=test, O="company, Inc.", L=City, ST=AL, C=US
Algorithm: RSA; Serial number: 0xb40b909f74d167aa
Valid from Tue Sep 12 09:42:01 CDT 2006 until Thu Oct 12 09:42:01 CDT 2006
adding as trusted cert:
Subject: [email protected], CN=Employee, OU=test, O="company, Inc.", L=City, ST=AL, C=US
Issuer: [email protected], CN=ISAC Employee, OU=test, O="company, Inc.", L=City, ST=AL, C=US
Algorithm: RSA; Serial number: 0xb40b909f74d167ab
Valid from Tue Sep 12 09:49:12 CDT 2006 until Thu Oct 12 09:49:12 CDT 2006
adding as trusted cert:
Subject: [email protected], CN=company Employee, OU=test, O="company, Inc.", L=City, ST=AL, C=US
Issuer: [email protected], CN=company, OU=test, O="company, Inc.", L=City, ST=AL, C=US
Algorithm: RSA; Serial number: 0xf6e3ada87dc4004f
Valid from Tue Sep 12 09:40:32 CDT 2006 until Thu Oct 12 09:40:32 CDT 2006
init context
trigger seeding of SecureRandom
done seeding SecureRandom
instantiated an instance of class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
SSL socket created
%% No cached client session
*** ClientHello, TLSv1
RandomCookie: GMT: 1158089181 bytes = { 138, 112, 170, 91, 246, 86, 216, 146, 160, 188, 243, 154, 238, 132, 33, 219, 251, 3, 93, 25, 191, 247, 41, 14, 99, 135, 130, 23 }
Session ID: {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]
Compression Methods: { 0 }
[write] MD5 and SHA1 hashes: len = 79
0000: 01 00 00 4B 03 01 45 07 0A DD 8A 70 AA 5B F6 56 ...K..E....p.[.V
0010: D8 92 A0 BC F3 9A EE 84 21 DB FB 03 5D 19 BF F7 ........!...]...
0020: 29 0E 63 87 82 17 00 00 24 00 04 00 05 00 2F 00 ).c.....$...../.
0030: 35 00 33 00 39 00 32 00 38 00 0A 00 16 00 13 00 5.3.9.2.8.......
0040: 09 00 15 00 12 00 03 00 08 00 14 00 11 01 00 ...............
Client Thread, WRITE: TLSv1 Handshake, length = 79
[write] MD5 and SHA1 hashes: len = 107
0000: 01 03 01 00 42 00 00 00 20 00 00 04 01 00 80 00 ....B... .......
0010: 00 05 00 00 2F 00 00 35 00 00 33 00 00 39 00 00 ..../..5..3..9..
0020: 32 00 00 38 00 00 0A 07 00 C0 00 00 16 00 00 13 2..8............
0030: 00 00 09 06 00 40 00 00 15 00 00 12 00 00 03 02 .....@..........
0040: 00 80 00 00 08 00 00 14 00 00 11 45 07 0A DD 8A ...........E....
0050: 70 AA 5B F6 56 D8 92 A0 BC F3 9A EE 84 21 DB FB p.[.V........!..
0060: 03 5D 19 BF F7 29 0E 63 87 82 17 .]...).c...
Client Thread, WRITE: SSLv2 client hello message, length = 107
[Raw write]: length = 109
0000: 80 6B 01 03 01 00 42 00 00 00 20 00 00 04 01 00 .k....B... .....
0010: 80 00 00 05 00 00 2F 00 00 35 00 00 33 00 00 39 ....../..5..3..9
0020: 00 00 32 00 00 38 00 00 0A 07 00 C0 00 00 16 00 ..2..8..........
0030: 00 13 00 00 09 06 00 40 00 00 15 00 00 12 00 00 .......@........
0040: 03 02 00 80 00 00 08 00 00 14 00 00 11 45 07 0A .............E..
0050: DD 8A 70 AA 5B F6 56 D8 92 A0 BC F3 9A EE 84 21 ..p.[.V........!
0060: DB FB 03 5D 19 BF F7 29 0E 63 87 82 17 ...]...).c...
Client Thread, received EOFException: error
Client Thread, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Client Thread, SEND TLSv1 ALERT: fatal, description = handshake_failure
Client Thread, WRITE: TLSv1 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 01 00 02 02 28 ......(
Client Thread, called closeSocket()
Error: Remote host closed connection during handshake
Thread-4, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake(I am the original poster of this message, I had to create a new username though).
The original problem had to do with incompatibilities with the protocol and/or cipher suites
used. Now, the client and server perform most of the handshake process, but something
goes wrong as the server requests the client certificate. In other words, the server requires
mutual authentication, but for some reason it seems like my JSSE client won't send over
it's client certificate. I don't get any type of bad certificate exceptions, so I'm not sure
where the source of the error lies.
Updated output:
setting up default SSLSocketFactory
use default SunJSSE impl class: com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl is loaded
keyStore is : keystore
keyStore type is : jks
keyStore provider is :
init keystore
init keymanager of type SunX509
trustStore is: truststore
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert:
Subject: [email protected], CN=Employee, OU=default, O="default Inc.", L=default, ST=AL, C=US
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Algorithm: RSA; Serial number: 0xb40b909f74d167ab
Valid from Tue Sep 12 09:49:12 CDT 2006 until Thu Oct 12 09:49:12 CDT 2006
adding as trusted cert:
Subject: [email protected], CN=default-Server, OU=HawkEye, O=default, L=default, ST=AL, C=US
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Algorithm: RSA; Serial number: 0xb40b909f74d167ac
Valid from Tue Sep 12 14:42:28 CDT 2006 until Thu Oct 12 14:42:28 CDT 2006
adding as trusted cert:
Subject: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Algorithm: RSA; Serial number: 0xf6e3ada87dc4004f
Valid from Tue Sep 12 09:40:32 CDT 2006 until Thu Oct 12 09:40:32 CDT 2006
init context
trigger seeding of SecureRandom
done seeding SecureRandom
instantiated an instance of class com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
%% No cached client session
*** ClientHello, TLSv1
RandomCookie: GMT: 1158242806 bytes = { 71, 195, 185, 44, 86, 96, 14, 11, 171, 76, 105, 135, 136, 114, 53, 54, 137, 75, 202, 254, 112, 208, 240, 91, 199, 246, 175, 207 }
Session ID: {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]
Compression Methods: { 0 }
Client Thread, WRITE: TLSv1 Handshake, length = 79
Client Thread, READ: TLSv1 Handshake, length = 74
*** ServerHello, TLSv1
RandomCookie: GMT: 1158242807 bytes = { 63, 93, 48, 73, 98, 251, 160, 215, 61, 110, 246, 12, 5, 209, 95, 194, 152, 193, 0, 181, 135, 26, 150, 174, 52, 92, 56, 250 }
Session ID: {83, 31, 134, 30, 76, 200, 183, 120, 7, 94, 26, 65, 186, 91, 197, 25, 10, 193, 94, 220, 198, 250, 162, 153, 6, 89, 12, 250, 66, 105, 249, 211}
Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA
Compression Method: 0
%% Created: [Session-1, TLS_RSA_WITH_AES_128_CBC_SHA]
** TLS_RSA_WITH_AES_128_CBC_SHA
Client Thread, READ: TLSv1 Handshake, length = 1903
*** Certificate chain
chain [0] = [
Version: V3
Subject: [email protected], CN=Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5
Key: Sun RSA public key, 1024 bits
modulus: 164546130673614659100546464587508805401937082626997447139358150641653094778762702643605529386963945060462618417820295217144739538713137107756847225226998964727905246706969036839701385553183842454061172884072035749790213037240682893878786969498404371282074360019097248835858617183835587887295684928062301303789
public exponent: 65537
Validity: [From: Tue Sep 12 09:49:12 CDT 2006,
To: Thu Oct 12 09:49:12 CDT 2006]
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
SerialNumber: [ b40b909f 74d167ab]
Certificate Extensions: 4
[1]: ObjectId: 2.16.840.1.113730.1.13 Criticality=false
Extension unknown: DER encoded OCTET string =
0000: 04 1F 16 1D 4F 70 65 6E 53 53 4C 20 47 65 6E 65 ....OpenSSL Gene
0010: 72 61 74 65 64 20 43 65 72 74 69 66 69 63 61 74 rated Certificat
0020: 65 e
[2]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C8 EA 02 93 42 9E 44 D1 55 7D 2D 32 4B 9B 1C 6D ....B.D.U.-2K..m
0010: 63 6B 73 82 cks.
[3]: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 2C BC 66 DC 06 BA 62 79 3B 1A 20 92 E0 81 71 A0 ,.f...by;. ...q.
0010: 0D 05 3C 95 ..<.
[[email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US]
SerialNumber: [ f6e3ada8 7dc4004f]
[4]: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:false
PathLen: undefined
Algorithm: [SHA1withRSA]
Signature:
0000: BF 60 5A 67 3E E6 F0 92 4F E4 81 6D 71 0A 2E E8 .`Zg>...O..mq...
0010: F3 59 A1 87 7B D1 3A 7A CB FF D6 39 63 79 B6 82 .Y....:z...9cy..
0020: 2A 22 D0 46 51 30 6B 2A 61 6B A0 4C F0 3B CE 5B *".FQ0k*ak.L.;.[
0030: 9C 1D 46 CB D7 C2 B2 23 E2 A5 06 CD 12 F8 A9 CB ..F....#........
0040: B5 A2 43 B1 06 4C 42 B5 67 F2 DF 50 6B BC 8A 5E ..C..LB.g..Pk..^
0050: 95 0D F3 2A 73 A8 5A C8 55 77 D7 36 74 16 9E 05 ...*s.Z.Uw.6t...
0060: 85 C6 DC 3C 44 D3 06 5E 47 0C 1F 80 40 30 C7 D8 ...<D..^G...@0..
0070: 8C 27 FF B9 0C 71 EB D4 31 5C 1F 15 A1 23 6F A2 .'...q..1\...#o.
chain [1] = [
Version: V3
Subject: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5
Key: Sun RSA public key, 1024 bits
modulus: 140862286957037297158683104484469503810921697537964422595574798580128510755934413463045842414762254029728885690233847950678735782281077619629628663140568366247472189890316085560712610474766899389736269383565795688749374256479726939861138704211990111677657317335172626254520371267441364353295155431963634875809
public exponent: 65537
Validity: [From: Tue Sep 12 09:40:32 CDT 2006,
To: Thu Oct 12 09:40:32 CDT 2006]
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
SerialNumber: [ f6e3ada8 7dc4004f]
Certificate Extensions: 3
[1]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 2C BC 66 DC 06 BA 62 79 3B 1A 20 92 E0 81 71 A0 ,.f...by;. ...q.
0010: 0D 05 3C 95 ..<.
[2]: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 2C BC 66 DC 06 BA 62 79 3B 1A 20 92 E0 81 71 A0 ,.f...by;. ...q.
0010: 0D 05 3C 95 ..<.
[[email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US]
SerialNumber: [ f6e3ada8 7dc4004f]
[3]: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:true
PathLen:2147483647
Algorithm: [SHA1withRSA]
Signature:
0000: AB 84 38 1F 7B 71 D8 87 FF 24 DB C2 7E DC D0 0B ..8..q...$......
0010: 60 60 14 A8 F8 D5 46 AD 6B FC 33 90 6F 43 08 17 ``....F.k.3.oC..
0020: AE 2B EE 6C 2B 29 85 E2 A6 67 EE 5D A4 61 F3 9E .+.l+)...g.].a..
0030: E7 CA B1 27 F9 11 36 ED 93 05 7B E1 20 90 57 B5 ...'..6..... .W.
0040: C6 F9 8A 9D 50 CD B3 4A 54 DC 1B 52 EC EA 7A 0B ....P..JT..R..z.
0050: B6 E6 95 FD DD 80 BE 66 F0 77 F4 E7 9A 8A A3 EF .......f.w......
0060: 9B 68 57 0C 9C 4B 4C C0 24 C5 34 16 D3 8E 45 27 .hW..KL.$.4...E'
0070: CA 23 F1 E0 C5 5E FB FB AA 1C 21 6E CB 5B 57 D9 .#...^....!n.[W.
Found trusted certificate:
Version: V3
Subject: [email protected], CN=Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5
Key: Sun RSA public key, 1024 bits
modulus: 164546130673614659100546464587508805401937082626997447139358150641653094778762702643605529386963945060462618417820295217144739538713137107756847225226998964727905246706969036839701385553183842454061172884072035749790213037240682893878786969498404371282074360019097248835858617183835587887295684928062301303789
public exponent: 65537
Validity: [From: Tue Sep 12 09:49:12 CDT 2006,
To: Thu Oct 12 09:49:12 CDT 2006]
Issuer: [email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US
SerialNumber: [ b40b909f 74d167ab]
Certificate Extensions: 4
[1]: ObjectId: 2.16.840.1.113730.1.13 Criticality=false
Extension unknown: DER encoded OCTET string =
0000: 04 1F 16 1D 4F 70 65 6E 53 53 4C 20 47 65 6E 65 ....OpenSSL Gene
0010: 72 61 74 65 64 20 43 65 72 74 69 66 69 63 61 74 rated Certificat
0020: 65 e
[2]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C8 EA 02 93 42 9E 44 D1 55 7D 2D 32 4B 9B 1C 6D ....B.D.U.-2K..m
0010: 63 6B 73 82 cks.
[3]: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 2C BC 66 DC 06 BA 62 79 3B 1A 20 92 E0 81 71 A0 ,.f...by;. ...q.
0010: 0D 05 3C 95 ..<.
[[email protected], CN=default Employee, OU=default, O="default, Inc.", L=default, ST=AL, C=US]
SerialNumber: [ f6e3ada8 7dc4004f]
[4]: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:false
PathLen: undefined
Algorithm: [SHA1withRSA]
Signature:
0000: BF 60 5A 67 3E E6 F0 92 4F E4 81 6D 71 0A 2E E8 .`Zg>...O..mq...
0010: F3 59 A1 87 7B D1 3A 7A CB FF D6 39 63 79 B6 82 .Y....:z...9cy..
0020: 2A 22 D0 46 51 30 6B 2A 61 6B A0 4C F0 3B CE 5B *".FQ0k*ak.L.;.[
0030: 9C 1D 46 CB D7 C2 B2 23 E2 A5 06 CD 12 F8 A9 CB ..F....#........
0040: B5 A2 43 B1 06 4C 42 B5 67 F2 DF 50 6B BC 8A 5E ..C..LB.g..Pk..^
0050: 95 0D F3 2A 73 A8 5A C8 55 77 D7 36 74 16 9E 05 ...*s.Z.Uw.6t...
0060: 85 C6 DC 3C 44 D3 06 5E 47 0C 1F 80 40 30 C7 D8 ...<D..^G...@0..
0070: 8C 27 FF B9 0C 71 EB D4 31 5C 1F 15 A1 23 6F A2 .'...q..1\...#o.
Client Thread, READ: TLSv1 Handshake, length = 13
*** CertificateRequest
Cert Types: RSA, DSS,
Cert Authorities:
*** ServerHelloDone
*** Certificate chain
*** ClientKeyExchange, RSA PreMasterSecret, TLSv1
Random Secret: { 3, 1, 27, 159, 38, 131, 132, 24, 47, 148, 161, 90, 7, 39, 189, 28, 178, 156, 20, 151, 220, 192, 239, 182, 115, 234, 99, 225, 68, 250, 199, 173, 96, 181, 78, 180, 238, 37, 243, 72, 19, 91, 249, 11, 49, 83, 1, 150 }
Client Thread, WRITE: TLSv1 Handshake, length = 141
SESSION KEYGEN:
PreMaster Secret:
0000: 03 01 1B 9F 26 83 84 18 2F 94 A1 5A 07 27 BD 1C ....&.../..Z.'..
0010: B2 9C 14 97 DC C0 EF B6 73 EA 63 E1 44 FA C7 AD ........s.c.D...
0020: 60 B5 4E B4 EE 25 F3 48 13 5B F9 0B 31 53 01 96 `.N..%.H.[..1S..
CONNECTION KEYGEN:
Client Nonce:
0000: 45 09 62 F6 47 C3 B9 2C 56 60 0E 0B AB 4C 69 87 E.b.G..,V`...Li.
0010: 88 72 35 36 89 4B CA FE 70 D0 F0 5B C7 F6 AF CF .r56.K..p..[....
Server Nonce:
0000: 45 09 62 F7 3F 5D 30 49 62 FB A0 D7 3D 6E F6 0C E.b.?]0Ib...=n..
0010: 05 D1 5F C2 98 C1 00 B5 87 1A 96 AE 34 5C 38 FA .._.........4\8.
Master Secret:
0000: 0E 63 38 16 86 A1 84 72 33 2C D7 07 D7 C3 AC E0 .c8....r3,......
0010: AD 5B CD 3B 2E 2A 02 91 1E FE 17 97 4E 3B 56 C3 .[.;.*......N;V.
0020: 5D 0F 7A 99 90 0D 3D 4E 5F 39 C5 EB 6E AD DA 71 ].z...=N_9..n..q
Client MAC write Secret:
0000: 99 32 FA 60 0B 88 36 CD 88 02 D5 4A CA D2 A6 49 .2.`..6....J...I
0010: 69 60 42 B6 i`B.
Server MAC write Secret:
0000: 43 3F 85 72 FB 6D 28 1C BA 1E 8A 26 56 DE 18 FB C?.r.m(....&V...
0010: 01 83 20 7F .. .
Client write key:
0000: 6F 58 29 AB B3 8C F5 75 3C 70 04 DF 9D 01 43 F5 oX)....u<p....C.
Server write key:
0000: 4A D7 E9 63 53 32 78 DF E0 99 89 60 A4 1A 3C E7 J..cS2x....`..<.
Client write IV:
0000: 24 FB 0E 12 AB D2 70 6D 80 B1 B2 BC 78 1A 55 88 $.....pm....x.U.
Server write IV:
0000: E4 75 62 25 46 95 0F 7A 44 16 E2 39 38 AD 29 CD .ub%F..zD..98.).
HawkEye Client Thread, WRITE: TLSv1 Change Cipher Spec, length = 1
*** Finished
verify_data: { 98, 254, 245, 75, 252, 23, 91, 164, 67, 197, 69, 44 }
Client Thread, WRITE: TLSv1 Handshake, length = 48
Client Thread, READ: TLSv1 Alert, length = 2
Client Thread, RECV TLSv1 ALERT: fatal, handshake_failure
Client Thread, called closeSocket()
Client Thread, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
Error: Received fatal alert: handshake_failure
Thread-4, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure -
How can I connect multiple clients to a single client ?
I am currently developing an instant messaging program.I created a server and connected multiple clients to it by using thread logic.However I do not know how to connect multiple client to a single client.
What shall I do for that?Does anybody know a good tutorial or sample program?Or shall anybody explain me what I shall do for building the Instant Messaging part of my chat program?
Thank u in advance.You may use UDP multicast socket. But since you are using the UDP protocol you might risk losing the data that you send since UDP does not guarantee the safe transfer of data.
Alternately, you might create a server that allows multiple client to connect to it whose connection Socket objects are then stored in a Vector <Socket> object. The server then sends back data to the connected client about the other clients connected to it. Now when the client wants to send data (like an IM) to another connected client, it has to send a request to the server specifying the client login name and the server in turn streams that particular client's Address and Port to the requesting client. The requesting client then initiates the connection with the other client and then starts a conversation. One more thing, when the client communicates it needs to send information to the server like the name by which it likes to be referenced. In this scenario the server acts like a central repository for clients to query the existence of other clients in the chat room. Each client here runs a thread that listens to incoming connections and when a connection is established, may be opens a IM window or something.
The third option is to make the server to relay the information from one client to another. Like say, I'm connected to whoopy server and i want to send "Hello" to jackson, then i send the message (ie, Hello) along with the name of the client to which i wish to send it to (ie, jackson). The server then performs a lookup in its Vector <Socket> object and then initiates a connection with jackson and sends the information. However, this method is pretty costly in that you will be wasting a lot of processing behind the server.
--Subhankar
P.s. If you stumble upon any other brilliant ideas let me know.
Maybe you are looking for
-
Create a JTable based on an ArrayList containing instances of a class.
I have a class, IncomeBudgetItem, instances of which are contained in an ArrayList. I would like to create a JTable, based on this ArrayList. One variable is a string, while others are type double. Not all variables are to appear in the JTable. The i
-
When downloading from library using ADE and transferring to my kobo touch I get the above error message on my Mac computer. Can anyone help me figure this out?
-
HELP! - How do I append swf files together?
I currently have a swf slideshow (EHS.swf) and would like to append another as a continuation (EHS1.swf). My problem is - EHS1.swf appends but plays very fast. My current fps for both files are 20fps. I would like to append more, but I can't seem to
-
Offset for calenderyr/month
Dear Experts, I have a report in which there is a characterictic claenderyr/month. Input paramter is claenderyr/month which is restricted by a variable of type interval. i mean user will calenderyr/month as interval say 04.2009 to 06.2009 .. I have i
-
Save as Version Set not working
I am using Elements 9, and the Save as Version Set has stopped working.