Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to know if my RMI port is available or if busy. While I know that an exception will be thrown if it cannot connect, I would like to have that under control - to show a message "Connection Failed" and stop the process. (I am working with Eclipse). How can that be done?
Generally you cannot control ports, its sort of a first come first served. If you want to listen at a port say 3306, just try and open a server socket on it, if the process of binding fails its because its already in use.
RMI runs at a specific port, and so perhaps your question is about client side sockets in which case you only need to make sure that the RMI service is running?
Assuming u want to find out if RMI is running, u cud try establishing an RMI service at that port, if it fails because of a "Refused to connect" Exception, then RMI is not running
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to design a software in java. I have a client program in my personal computer which is located in a LAN. In other pcs of this LAN server application has been installed. So the image of my system is like this:
Ok, in this system servers have not same port , because some ports may close in each system, these servers just listen to a connection after finding an open port , as well Client doesn't know their IP, but as I mentioned all of these servers and client program are located in a LAN, picture of client program is some thing like this:
When I click the Scan NetWork Button , Client should find all of the listener servers in network , what should I do in this case? Is it possible to find all listener servers with a client in a network with cause I'm new to networking.
What you probably want is some kind of zero-configuration networking instead, like Bonjour/Zeroconf or SSDP. There are several Java implementations for both, as well as lots of native implementations on almost all OS.
They both solve your problem of finding the servers without knowing their IPs or ports.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What would be faster for a realtime game server, one port per user on the server in which each user is passed a thread and receives a port assignment, or one port per user in which each thread is handed the socket after being established on the main thread?
It's not a question of 'faster'. Once a connection is established it doesn't matter. The real issue is that your first alternative is not implementable without a lot of extra code which in itself will slow things down in the connect phase. A TCP server socket listens on a single fixed port which the clients know about, and they all connect to that port. If you then want to move them to another port you then have to open it, tell them what port it is, and accept another connection. It's all pointless.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a small client server app , that involves the client pinging the server on a set of ports ( 90,6100,6200).
I use inet.isReachable(30000) to monitor whether the server responds to the client or not.
In the end , I want to make sure that when I re-run my application , any existing connections to these ports are removed.
How do I go about doing so ?
And is there a way to automatically close a connection when I am using InetAddress, which does not seem to have any method to terminate an existing connection to an address ?
"I want to make sure that when I re-run my application , any existing connections to these ports are removed."
The connections cannot stay open when your application exits - there is no process for them to be connected to. So in that sense, you don't have to worry about closing them on next launch.
"And is there a way to automatically close a connection when I am using InetAddress, which does not seem to have any method to terminate an existing connection to an address ?"
Yes - the connection will close when isReachable is responded to, or when the timeout expires (or some other error occurs). Just creating an InetAddress does not create a connection - it automatically creates and destroys them as needed to do its functionality. Connections are generally just short lived things that don't stay open unless you make them.
The JVM will close the connection after the server responds to isReachable or the timeout expires, whichever comes first.
The answer to your vague question is that as connections don't survive the process they are created by, and as INetAddress"isReachable() doesn't leak connections, there is no actual problem here to solve.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to make a multi-client application in which somebody is the host and other people join into the game. I need this to be possible without port forwarding so that users can easily set up their server. Is this possible without any help from any of those server hosting companies that help out? Is there any special port that doesn't require port forwarding?
As far as I know, the only possible approach is to use UPnP (Universal Plug and Play). More specific: Internet Gateway Device Protocol (IGDP). This makes the port forwarding go automatically. It is a protocol that has the possibility to ask the gateway to forward a port to your machine. So this isn't really "without" port forwarding, but it will do it automatically, instead of the user having to go and configure their router.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
There is a server listening incoming connections to a given port. Suppose server is 172.16.5.26 and port is 4099. When I scanned this as
nmap 172.16.5.26 -p 4099
I'm able to get the ip address of client. But when TCP half open connection is requested as
nmap -sS 172.16.5.26 -p 4099
I'm unable to get the IP address of client. I'm looking for a method in java to do this task. If there is no such inbuilt method in java library, is there any way to accomplish the task ?
Socket.getRemoteAddess() and friends. But these assume the connection is to your JVM and that this is the corresponding socket. If you're looking for a Java method to find arbitrary half open connections anywhere in the host there isn't one.
What's the motivation here? Why do you need this?