Hi, I am wondering if it is possible to "transfer" a Socket connection to another ServerSocket?
So, say I listen for a connection on ServerSocket with port 1111. A connection is established, I know want to use a ServerSocket with port 2222 to handle this connection. Is he possible without listening for a new connection on that port?
Can you explain What do you want to do when the ServerSocket's accept() method returns a Socket with a connection? Normally you would pass that Socket to a class and method to handle it. Why can't you do that?
Yes I will pass it to a class to handle it but first I would like the connection to switch to another serversocket meaning the first serversocket is now free to accept another request very fast if you undertsand it
That is what I suggested as being the normal way to do it. When accept returns with a connection, the socket is "switched" to a class and method on its own thread to handle and the program loops back immediately to wait for another connection on that port by using accept.
You can have one ServerSocket that sits waiting in a loop accepting connections and passing each one to a new Thread that handles ongoing communication with that client. There's no need to change to a new port to do that.. Ie you can have one ServerSocket and multiple Sockets on a single port.
Ah well, the reason I wanted this was for load-balance, so connection goes to first free ServerSocket. So if I have load of http request at one time it can transfer connection to a free server which will then handle request.
So how many server computers are you talking about? If you want to hand the connection off to a different computer in a server farm, then sorry, I don't know how to do that. If it's two threads on the same machine then there's no advantage in changing ports.
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...