Server in web which allow test socket gathering info - java

my question is quite hard to formulate.
Well, is there any server in whole web which one would be able work with testing sockets?
For example to send to server "somehow" and get hmm.. time in the world, or any fancy info.
Please correct english if i make mistake and topic if it makes missunderstood.

You could write your own or use http://code.google.com/p/softenido/wiki/echoserver. I think you can install simple tcp services in windows which will allow you to connect to echo on port 7. Of course you can always use open web servers:
c:\> telnet www.google.com 80
Then type "GET /" and hit enter twice. You should get google's web page.

Related

Can i host my ServerSocket or Java file somewhere on the web?

Heyy guys. I'm writing a chat application in java, works pretty well. But can i somehow host my Server file or the Serversocket on the web? I want to make it so my friends from other pcs can use the client and connect to the server file which is hosted on the web. Is that possible? Can i host the File/socket online?
When you run a java application that opens a ServerSocket, it opens a port on your local machine and starts listening for incoming connections. What you do with those connections is up to the implementation of the java code that you write.
The "web" is much less foreign than you are making it out to be. Your own computer can be on the web that you're talking about and people can connect to your chat service. Or you can choose to host it on something like an AWS server.
The following approach is assuming you are behind a pretty standard NAT config.
Once you run your java application, you need to make sure other computers can see you, either inside your LAN or outside on the internet. You want to start testing from as close to your computer as possible, then start expanding outward.
First you need to make sure that your computer's firewall is actually allowing connections on the port that your java application is listening on.
Opening ports in the Windows Firewall
Setting up and opening ports in Linux
Now computers on your LAN will be able to connect to your java program. Now you need to go one layer out, and port forward your router. This is much less standard so I can't help you too much, but Google can.
At this point, anyone on this internet, knowing your external ip and what port your java application is listening, can connect to your service.
If you chose to host this on an third party hosting service, you'll need to go through similar steps, but there may be slight differences that you can either ask about, or again Google is a great resource.

HTTP or FTP for client/server application in java

im Trying to Write a Windows client-server Version control application .
i've created two servers , one works with java socket ( java.net library ) to handling the requests ( login, signup and ... ) coming from client . and the other server is running on FTP protocol (using apache common net library) for serving my files .
and client is able to communicate with the first server over tcp socket and download or upload files to the second server using FTP .
but recently someone just told me that i should use HTTP instead of both . because HTTP in java in really easy to use for both communicating and FILE serving and most importantly is its able to traverse the NAT which now what im using is not able to do .
now im wondering is he right ? should i change my servers to use HTTP instead of TCP socket and FTP ? whats the benefit ?
There's some advantages of changing your protocol stack to HTTP:
You can easily add security later (only a matter of a single 's')
You don't have to do two servers, you can do all-in-one.
At some point you could offer a browser-based access of you don't have the client installed / work of a decive where you cannot install it
HTTP webapps (even those in java) are proven to scale very, very well. So once you have a lot of users, you're still good to go.
There's a lot of helpful frameworks out there that can help you focus on the what instead of the how
Most companies that allow outside-access at all will have HTTP/HTTPS open. FTP is more limited in most places.
NAT traversal / Proxy traversal
and that's only the ones I came up with while typing :-)
Downsides:
You have to start over. But: If you run into trouble, Stack Overflow is there to help you out.

Failed port-forward for my diy application in Openshift

I have a java application with a server socket, but i don't know how to connect with another java web application in openshift. Looking in forums i saw i had to do port-forward to see wich ports i had to use in the connection between the web application(client) and the java application(server). But i have this error:
http://postimg.org/image/gjrrs80lp/
I did ssh -N 536(..) too, but it didn't work. I'm full blocked, i've never worked with sockets and ports and i'm blocked.
Thanks for the help guys ;)
You might do better to read up on sockets and ports then. Can you give a specific error that you are getting? If you are trying to use a non-supported port, then it will be blocked. If you want to do port forwarding between gears then you need to make sure you have a public/private key setup on your gears for that purpose and added to your account.

Getting information from a cisco / juniper router with java

What method could I use to login to a Cisco or Juniper routers? I know I can use telnet to make a connection to the router itself but I am not aware of an API or anything that allows me to login non-interactively. So how could I do this?
Are there any libraries I can use to achieve this?
I have seen people use scripts that implement things like expect to know when to send the username and the password. But that is for shell scripting. How can I do this in java? I would prefer to keep strictly in java too.
The goal of this is allow a java program login into a router so I can query the router for interface states and execute commands on the router.
Any ideas?
You need to use some Java library for doing the same. http://www.pitman.co.za/projects/jssh/ is a good Java SSH client. http://commons.apache.org/proper/commons-net/ has a good telnet implementation
As far as extracting information, you should be able to do it by using SNMP to query the router. Pretty much everything is available over SNMP. Now, as far as command execution, there are SNMP set commands used to "write" information to a router, but you will need to look into that more carefully as I doubt the full command set can be replaced with SNMP set commands.
For Cisco, find out what the IOS image filename is for your device, then you can get the MIB file here: http://tools.cisco.com/Support/SNMP/do/MIBSupport.do?local=en&step=3. Review the MIB file and you will see what is available via SNMP for that device.
You should be able to do something similar for Juniper on their site.
Now, I don't know much about Java, but I do know that there are SNMP libraries available for it (like http://www.snmp4j.org/ ).
With that you will not need to worry about logging into the router, or about any interactive stuff.
Note that, in the case of Cisco, it's common to connect using a serial port on a PC directly into the service port on the router. This connection uses a programming protocol called IOS.
The easiest way to utilize this is with a programming language called expect. This name describes the language in that you expect to get a prompt from the port and then you respond. Sending that message (your response), you expect to get another response, to which you respond, ad completum - my term ;)
Note that this cable is proprietary to Cisco, I'm sure there are pin-outs available though.
Finally, it would be possible to emulate this program on java, via a serial port library.

How to debug Java Server working for localhost but not public IP

Noob question but I'm not sure where to look:
I'm running a Java Web App on a remote linux machine (Jersey RESTful API is the goal). The server successfully runs and can handle requests locally to localhost:8080/foobar but I cannot make requests to the various urls from anywhere else (For example, my laptop through a browser).
This is a simple problem I've have many times but have no idea what terms to search on google or where to look for help debugging the problem, so any leads or advice would be greatly appreciated.
Further details:
Project is code added to a Maven2 generated archetype of a Jersey Service
This is most likely caused by firewalling on the server or in front of the internal network your server is running on. Talk to your network administrators about opening a hole for port 8080, or consider using a reverse proxy on port 80 (if open) to forward requests to port 8080. See http://en.wikipedia.org/wiki/Reverse_proxy if you are not familiar with the idea of a reverse proxy or load balancers.
Change the localhost entry in your "/etc/hosts" file, with the network configs, and if server is tomcat, edit the $CATALINA_HOME/conf/server.xml to add IP the relevant <Connector> element.
Make sure you have better idea handling /etc/hosts

Categories

Resources