How to programmatically find availability of a port in a given machine using java?i.e given a port number whther it is already being used .
|
I'm very new to socket programming:
Is it possible to explicitly set the the source port on a Java Socket?
I am working on a client/server application in which clients could potentially ... |
If you create a TCP client socket with port 0 instead of a non-zero port, then the operating system chooses any free ephemeral port for you. Most OSes choose ephemeral ... |
I am writing a port scanner in Java and I want to be able to distinct the following 4 use cases:
- port is open
- port is open and server banner was read
- port is ...
|
Hi
I want to read the data from a port example 1234 which is always listening some application buffers data on that port. Now I have to read that port and print ... |
Thanks for any answers in advance.
Anyways, I made an android application, (This isn't an android question), and it connects to your computer so you can monitor it. Well I have the ... |
I have an app in java that is nothing but a remote server.The remote server I wanna design to accept two kinds of client:
1.Some that connect at 127.0.0.1 at the port ... |
|
I am running some java code on CentOS 5
java Something.java &
that creates a socket on a certain port....say 9090..however, the code doesn't run completely and so I Ctrl-C out of ... |
This is my first time working on Java so please do correct me if I'm asking the wrong questions here.
My requirement is really simple. A server software is regularly sending ... |
For firewall reasons (beyond my control) I need to set the local port to a given range. Is there a means to set the low level socket values to bind the ... |
I wrote this java J2SE code :
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TwoWaySerialComm
{
public TwoWaySerialComm()
{
...
|
All riiiiiight! So, I made a networked game in Java using Sockets. It works great, except... only through my LAN. :/ What I want to be able to do is set ... |
Given this:
. . .
ServerSocket serverSocket = new ServerSocket(1111);
while (helperSockets.size() < Common.NUM_HELPERS) {
Socket helperSocket = serverSocket.accept();
. . .
This throws the exception:
new Socket("localhost", 1111, InetAddress.getLocalHost(), localPort);
Exception:
java.net.ConnectException: connect: Address is ...
|
public static void test_socket(){ String host="localhost"; for (int i=0;i<50;i++){ try{ Socket sc=new Socket(host,i); System.out.println("There is a server at port "+i+" "); } catch(UnknownHostException e){ System.out.println("Host There is an error at port ... |
Hi I have a question about sockets. I read that each socket is uniquely identified by both an ip number and a port number. But I have a program that creates multiple sockets with IDENTICAL ip address and port number, and the multiple sockets run fine. Can someone help me understand what is really going on? Thanks. import java.net.*; import java.io.*; ... |
Hi Angela, You have made so many programs using ports and now u r asking what are ports? Anyway a port can be in simple terms called as a door for a particular address. for e.g. There is a postman with an envelope in his hands to be delivered. He has got the address of a building (that is your computer) ... |
|
|
|
hi! friends i've a problem in socket communication. the problem is that i want to get the free ports on the remote machine how can i do that. and i also want to check that on a remote computer a application is running on which port. if u have any idea then reply back. Ajay Singhal |
While writing a network application, I decided to set myself up so that if the port I wanted was already in use, the app would try the port + 1, infinitely until an available port was found. So I wrote the following code into the constructor of my connectionManager object: boolean err = false; do { try { System.out.println("Attempting to connect ... |
Aren't you asking how to scan for the varios port's status in Java? Not with a third party utility? If not I would like to know anyhow if anyone knows of a way. And beyond that perhaps. What process and pid are running on that port? In case you have to use a particular port and can not find which process ... |
hi ! i'm currently trying to implement an applet-based ftp client. i got it as far as i get ascii responses from the server, but when i say sth like "LIST", the server replies that he can't open the required connection. are binaries and directory listings being transmitted via a different socket ??? does this have to do with the PORT ... |
Originally posted by Roshan Dehipitiarachchi: U can write a simple java program which trys to open a server socket on the port number u are interested and if it is assinged an exeption is thrown. U can even do this in a loop so U can check a range of port numbers. |
Hi all - I apologise if this has been covered already, but I did a quick search and couldn't find an answer. I'm trying to find a way of finding out what ports/sockets are open on a machine at any point in time - so I'm after some method to return a list of open ports. Ideally I was hoping there'd ... |
This is usually done with firewalls. But if you really want to do it in Java, you can write a Java program that listens at port 80 and just discards all incoming information. On most systems, you have to be administrator to have your program bind to port 80. You must free port 80 first and then run this Java program. ... |
After setting both the http.proxyHost and http.proxyPort values in the system properties, if I change them the system lists the new ones properly, but does not use them properly. How can I make sure that new connections are made using the updated values? Example: I access site A using the first proxy setting. I get a result showing the IP of ... |
What kind of port scan? With normal Java sockets you can do a full TCP connect scan which is a noisey scan (the scanned system will know your IP address). Here's a quick and dirty example: import java.net.*; import java.io.*; public class PortScan { public static void main(String[] args) throws IOException { InetAddress host = InetAddress.getLocalHost(); int startPort = 1; int ... |
HI, When you want to receive data on one socket and send data on the defferent socket then i would say let your client and server have both client socket and server sockets . Client application will have server socket and client socket capability. Server application will have server socket and client socket capability. I mean like open a server socket ... |
Also a related question: Why do we actually need ports? I know, it identifies the service supplied by a server machine somewhere on any network. ex. SMTP Port 25. But is it standardised to be working at 25? One cannot configure it to be at 1024? (or anthing in the range [1024-65535] ) Wouldn't it be more convenient to embed the ... |
My company has various outgoing ports blocked, and I want to find out which ports are not blocked, so I can access my home computer. I've whipped up a little program that tests connections by trying to establish a socket connection on a given port. This only gets me halfway, however. In order for the connection to be established, both outgoing ... |
Hi to all, I ran a port scanner Java program (taken from the O'reilly Java Networking Book). The program identified various servers running on my localhost machine (localhost). My question is, what do I do to find out the names of the services/servers which are running on the ports? Here is the output of the program: There is a server on ... |
in the following code, it seems to me that a ServerSocket on port 3333 ought to be created, then it should wait for a connection, and then it should set up a Dialogue (extends Thread) with that socket. Then, it should reset itself. HOWEVER, it appears to be giving a number of Adress Already In Use Exceptions before reseting, which says ... |
|
|
Hello all, I am writting a Chat Server/Cleint program. I connect to the server using the port 5001. What I want to know is can I use the same port (5001) of the client to connect to another client for a Private Chat - Personal chat I mean. What I am trying to do is, making the one client a server ... |
Hi, I worte simple program (2 classes) One as a SocketClient Second as SocketServer Now, when I gave different port for both the socket connections. It gave Exception with message connection refuse: no further information. But I give same port no. it ran. But I need to give diffrent port. So that diffrent client could connect to my server. And server ... |
|
Imagine you computer as a House with many doors. The address of your house would be equal to the the IP address of a computer. Each door would be equal to a computer's port. A socket would sit at a door and listen and talk. A socket is an a a connection to another computer. It would sit at one of ... |
I appreciate any help and hope I can be a help to others in the future. Here is what I would like to achieve: Knowing the port number that is being used by a peice of third party software, I want to be able to monitor that port and see everything that is coming from the third party to my machine. ... |
When posting code, please use the code-tags. You may edit your post, and insert them later, if you forgot them - i.e.: now. --- To the content of your question: Normally, a service is running on a server, allowing multiple clients to connect to it. The port is a kind of adress, where the service is reachable. The server is started ... |
|
|
|
|
Hi folks, New to socket programming here. Please ignore if its too stupid. In sun site for What is a socket ? On the client-side: The client knows the hostname of the machine on which the server is running and the port number to which the server is connected. To make a connection request, the client tries to rendezvous with the ... |
Hi, My swt application on Eclipse platform is not able to listen on multiple ports. Each port is multi threaded. I want the action that I trigger from the UI (Buttons) should be threaded. How to do that? I have two buttons B1, B2 both will invoke diff ports e.g. B1->port no 5555 and B@-> port no 6666. By pressing B1 ... |
|
Hello All, on linux(2.4.21-32.ELsmp #1 SMP Fri Apr 15 21:17:59 EDT 2005 i686 i686 i386 GNU/Linux), when attempting to start tomcat5.0.28, I receive the error: StandardServer.await: create[8080]: java.net.BindException: Address already in use java.net.BindException: Address already in use I have verified 8080 is not being used by any process. I have changed the port in server.xml to 8888 and 88 and the ... |
hello, I have a problem, I need to test a link between my computer and a remote ip camera, and I need to do this really fast. so, I was trying to use the method isReachable but I need to find a way to set the port. there is any other kind or method that can I use to that situation? ... |
Hi When creating the server and client sockets how can i specify the same port in both of them When creating the server socket i can iterate through the port numbers and assigh the available port but how can the client know the port number to connect to the server socket.Can someone please let me know how to do this Thanks ... |
Hi a client has asked me about the details of the ports we are using and I dont know certain things like if they are inbound or outbound ports. Can anyone tell me about the following port numbers if they are inbound or out bound port number port type inbound/outbound 8083(ws) tcp both 11000(i m using it for ns) tcp ? ... |
Hi, for evaluation purpose, I will need to run multiple instances of my server program on a single physical machine. I got an Address Already in Use (the port is already in use?) for starting the 2nd instance of my server program. The line that throws the exception is: ss = ssf.createServerSocket(port); I just wonder whether there is a way to ... |
Try binding to them. Really there is no API call for this, and there should not be. Besides, attempting to bind a socket to an IP/Port combination takes about 1 millisecond, so choose a range of ports attempt to bind to them. But remember, with this method, and any hypothetical "free ports" method, just because a port is "free" this millisecond, ... |
It is very nearly impossible for a computer to have every single port in use. It is theoretically possible, but so impractical and improbable as to at least be considered, if not truely be, impossible. I have the feeling that you are attempting to bind the same port twice. Whether this is because of a loop, multiple threads, or whatever, I ... |
|
|
Hello , I'm new to socket programming , having problem to solve the following situation. I have an input file. I need to write a line from this file to the port and then read it from the port and process the line. I have to continue like this till i reach the end of the file. The purpose of writing ... |
I want my writing to a port to be asynchronous i.e. It doesnt matter if any application is listening or not, i should just be able to write. As noted before, that's not something sockets can do on their own. I've run into that requirement many times and built some kind of "store and forward" solution. For example, if the server ... |
|
Hi, I have this piece of code which checks if a port is available: private static boolean isPortAvailable(int port) { try { ServerSocket srv = new ServerSocket(port); srv.close(); srv = null; return true; } catch (IOException e) { return false; } } However, sometimes this function returns true (i.e. the port is availble), but when a external C program opens the ... |
Which of the following Java code snippets can be used to identify applications running on low port numbers? A. for (int i = 1; i < 1024; i++) { try { Socket s = new Socket("localhost", i); System.out.println("An Application is running on port number " + i ); }catch (UnknownHostException ex) { break; }catch (IOException ex) {} } B. for (int ... |
|
I am fiddling with getting a local server running. I had it running using port 8080 or 8000 or some such normally www/html port. I changed that to port 80 and the server gets thrown off the system at boot, so I am going to select some port(s) to start servers on, I am thinking of using the private ports (65535 ... |
You could try to open Socket connections to each port you're interested in. You probably want to make the code multi-threaded so you can open connections to many ports (or machines) at the same time, because it'll take a while for the connection attempts to time out if nothing is listening on that port. Keep in mind that port scanning is ... |
Hi I'm trying to develop a client server app for uni, but I keep getting a port out of range error. Here's the server code: public static void main(String... args) { SNS ns = new SNS(); System.out.println("NameServer started: "); ns.restoreNameTable(); try { ServerSocket listener = new ServerSocket(1975); while (true) { Socket aClient = listener.accept(); ns.handleClient(aClient); aClient.close(); } } catch (IOException e) ... |
|
We have written a BTB tool to transfer files from a client to a server application over FTP. The server application is written in Java and we used the JFTPD code as a baseline. In unit testing on a Windows box the code works perfectly. When we moved the server application to pilot on a unix box (Solaris) the application fails. ... |
The problem with trying to use a standard ping program to see if a machine will respond is that many machines and networks simply drop these sorts of requests so no response could mean various things. There are other ways to find out if a machine is running at an IP address. NMAP, Nessus can certainly do it, I have found ... |
Hi Everyone, I'm a newbie to Java and to sockets, so, please excuse the idiot questions. I should say now that I have solved this problem BUT I don't think I fully understand so I would be glad of your comments. The area of doubt relates specifically to port 5000. I've been working through the Head First Java book and got ... |
Hi All, I am trying to implement ssh port forwarding future in my code, i tried following steps with both Ganymed and JSCH libraries. I have two unix boxses tunnleFrom and ExtSystem. ExtSystem : where my stub is listning on port 10023, this stub is suppose to respond on incomning requests. tunnleFrm : where i have run ssh -g -L11023:ExtSystem:10023 user2@tunnleFrm ... |
I have written a simple program that opens a connection to a whois port on the InterNIC server, sends the command line argument down the socket, and then prints the data that is returned. But i am getting a ConnectException saying connection timed out. Below is the program import java.net.*; import java.io.*; class Whois { public static void main(String args[]) throws ... |
Hi, I am using OpenORB and do need to implement client socket creation myself because I ought to specify the port number to use for securiity reason. The default implementation picks ports numbre randomly. (been confirmed to me by OpenORB developers) I hade a look at the code and have not found where the client socket get created. From your CORBA ... |
|
There is an infinite amount of service that can "run on port 8080". Or any port. There is no enforcement that protocol x must use port a. Your best bet would be to examine what that application gets sent back. If it is a standard protocol it should be easy to ferret out, Such as HTTP or FTP, even specific instances ... |
|
In computers generally It has Mouse port ,Keyboard port ,etc.Also Computer has Port number 8080,80,etc.What are the difference between them. I read article says that port number ranging from 0 to 65535.It means computers should have 65535 ports(like mouse port ,keyboard port) Is there any restrictions to create a new port EX:45652652.. |
|
Sorry if this is not the right forum, Im not sure where this should go. But I have occassional problems with eclipse shutting down and when that happens tomcat will keep ports 80 and 8009 in use. WHen I restart eclipse it says tomcat is stopped, but when I hit start it tells me those ports are in use. Tomcat doesnt ... |
Sunil The actual requirement is to find a list of free ports b/n a range say between 7000 to 9000 we will just find a port say 7002 which is free then incrementally use other ports which are free untill the range 9000 to host our services. This has to work across all OS (HP ,IBM AIX,Sun Solaris,Windows) didnt get "In ... |
Hello friends, As usual .. when i have a problem ... coderanch.com is here ;). So I need some information from you. Ok, let me explain ... I am currently developing a chat application ! Ok ... everything works fine till now but I have doubts. My application uses 3 ports, one for the general chat room, one for personal chat ... |
|
|
|
need to connect to computer over tcp/ip i have the external ip but without port forwarding I can't connect to the server . Is there any way to configure the server to accepts connection on the external ip and port define by the server without configuring the router ? (how does emule, FogCreek CoPilot, LogMeIn does it ? or other peer ... |
Hi All, I have a program that checks available port numbers. Sometimes it reports that certain ports are not available but I cannot find what application is using them - I've tried netstat -aon. For the program I'm using: ServerSocket socket = null; try { socket = new ServerSocket(port); return true; } catch (IOException e) { return false; } finally { ... |
|
Hi All, I have implemented a port scanner in Java which has to check if certain ports are occupied. I am using a standard approach by creating a socket with each port and if there is no exception the port is available and if an exception is thrown it would indicate that the port is occupied. ServerSocket socket = null; try{ ... |
|
Hi guys, I've stumbled across one problem which is quite frustrating for me since I don't know much about it. The idea is this: I have a user flooding one of my ports with connections. As far as I know there isn't much things stopping Server Socket from accepting all of those connections. So what I need is pretty clear, to ... |
i try to check....which port is busy...or listen mode...... but its give EXCEPTION....... import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; public class port { public static void main(String[] args) { String host = "localhost"; // String host = "123.237.108.59"; for (int i = 1; i < 1024; i++) { try { Socket s = new Socket(host, i); System.out.println("There is a server on ... |
hi, i would be grateful if some information can be provided to me for my problem below : developing a two port multi-threaded server which lets clients connect on two different ports. the server can handle multiple clients. At the moment i have been able to develop the the server which reads and writes on the two ports with multiple clients ... |
|
i have a requirement to fix the server and client ports being used by our RMI app. i understand that fixing the client port is a bad option as it would obviously cause performance issues. So i am working on fixing the ports being used on the server side. Till now i have created a custom RMI SocketFactory that uses a ... |
|
Is it possible to write code using pure Java to port-forward from your router. The PS3 and other programs do it. I would like to know how to do this in Java. What I mean is, without setting up your router, how would you set up port-forwarding so your program could become a server. I am sorry if this is really ... |
Howdy, I'm attempting to start an instance of a glassfish server immediately after I've (gracefully) stopped it. When I try to restart it I get the following error: There is a process already using the admin port 4849 -- it probably is another instance of a GlassFish server. The problem is I do a netstat looking for the process that owns ... |
Hello, I want to write a java japplet application which will handle multiple chat rooms with sockets. There can be 1 or more chat rooms running at a time with 1 or more users in each chat room. Would each chat room get its own port number that the socket is using? And everyone in that chat room would use the ... |
public static void main(String[] args) { Socket s = null; String line = null; try { s = new Socket("localhost", PORT); DataInputStream sin = new DataInputStream(s.getInputStream()); line = sin.readLine(); if (line != null) System.out.println(line); } catch (IOException e) {System.err.println("!" + e);} finally { try { if (s != null) s.close(); } catch (IOException e2) {} } } } And this is ... |
hello everyone! i have a java.net.ServerSocket listening on port 5000. "normal" users can connect to it, but those who sit behind a school/office/etc LAN can't use port 5000, only port 80 (and sometimes 443), so they can't connect. is there a way to make the client connect to server:5000 using local port 80? tnx |