jQuery in Action, 2nd edition*
The moose likes Sockets and Internet Protocols and the fly likes Baby Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Baby Question" Watch "Baby Question" New topic
Author

Baby Question

Eric Barnhill
Rancher

Joined: Feb 25, 2000
Posts: 233

I'm working out of a tutorial book and trying to get my EchoServer program running. I've got my own domain that is hosted remotely by a commercial service. What do I need to do, besides just uploading the class file, to get my EchoServer loaded up and listening on its port (which in this case is 5555)?
Right now EchoServer.class sits in my home directory, but connecting to port 5555 yields an error. I presume I'm missing a step.
Thanks a lot
Eric B.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I don't want to teach you to suck eggs, but you will need to run your class file:
java EchoServer
If you have done this and it's still not responding there may be some confusion with ports. The first step with any Java server development is to run the server locally and try it with IP address 127.0.0.1 (the standard "loopback address"). This should let you make sure that your code is correct, without having to worry about remote machine configurations, proxys and firewalls etc.
Let us know how you get on.
[This message has been edited by Thomas Paul (edited June 05, 2000).]


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The other possibility (assuming he is running the class file) is the host is blocking all ports other than the ones they are specifically using.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Eric Barnhill
Rancher

Joined: Feb 25, 2000
Posts: 233

Thanks for your help. Actually I have no access to a command line at all. All I can really do is ftp to this site and send it files. I can do some things indirectly (like a chmod on my CGI scripts). But the server wouldn't pay attention to my attempt to send it a "java EchoServer" command (using Fetch for the Mac). I tried.
Toldya this was a baby question!
Thanks again,
Eric B
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
If the server will run CGI scripts, then you can get it to run any code that you like.
Put "java EchoServer" into a file called (for example) start-echo.cgi and transfer that file to the server using ftp, you can then execute your instructions as a cgi script.
Note that this will give a "server error" in the browser, because it doesn't return any response. Ignore that, and see if your server is running.
This may or may not work, depending on the details of the server machine. If you can give us more details of the machine you want to run your EchoServer on (what OS, what Web server etc.) we can probably come up with a more robust solution. Unless the server doesn't have Java installed at all, of course ...
Eric Barnhill
Rancher

Joined: Feb 25, 2000
Posts: 233

Thanks for the help.
It doesn't seem to be running the class file, but I was thinking there might be a directory issue here - I know at work I always need to be in the bin folder of the JDK before I can run anything.
The script just said:
---
#!/bin/sh/
java EchoServer
---
This is a Unix server, and the hosting company says they support Java....
Thanks
Eric B.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Now we're getting somewhere.
Try the following script:

to find where java lives (it might take several minutes to run).
Note that I look for "javac", even though I want to find where
the Java interpreter ("java") lives; on most systems with Java installed, there are several other directories and files called "java" which we are not interested in.
This should give you back a list of locations containing javac:
<pre>/usr/java/bin/javac
/usr/java/jdk1.2.2/bin/javac
/usr/local/java/1.1.8/bin/javac</pre>
etc.
Choose the most reasonable looking one and hard-code the path of the associated java into your startecho CGI script:

If the server starts running, and continues after the CGI has exited, you will need another CGI to stop it using "kill", so note down the process number of the server shown by "ps".
This approach can be made as elaborate as you wish. A general purpose control CGI with start and stop buttons, or even a general "command-line" box in a web form which sends your command to the server and executes it is a possibility (although do be careful about security...)
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Try to use telnet to access your server,if it works, It's much easy to solve your question.
Eric Barnhill
Rancher

Joined: Feb 25, 2000
Posts: 233

So, do you think this had something to do with my problem? I wrote to tech support with the following question:
<pre>
>Hello,
>
>what's the path to the java runtime environment on the server, so I can
>load up a java .class file in a shell script?
>
>also, is there any way for me to telnet into my site? It would make life
>so much easier!
>
>Eric B.
</pre>
and got back:
<pre>
>Hello,
>There is no path to java just upload it to your account and
>everything should be fine, also there is no telnet access
>permitted at affinity. If you have any further questions please
>let us now.
>Thank you,
>Mike Sanford
>Affinity Internet, Inc.
>Technical Support
</pre>
Let me say, just to save a little face, that Affinity's home page says they support "Programs and Programming Languages" that include "Java" and "JDK" right here. Obviously I wildly interpreted what this meant.
Jeez, even my rinky-dink free homepage that came with my dial-up account has jdk1.1.8 on the server - I've fiddled with it through telnet. Unfortunately the page is so rinky-dink it doesn't run cgi scripts, it just prints them on the screen. So I naturally assumed that my paid-for page with a fancy hosting company, which says in their ads that they support Java, might actually HAVE Java on their system.
If I upload the entire JDK, of course, I'll go well over my size alloted at the Affinity account.
This is a real bind! I'll have to get back to you when I have a solution.

Thanks for your help as always.
Eric

[This message has been edited by Eric Barnhill (edited June 08, 2000).]
[This message has been edited by Eric Barnhill (edited June 08, 2000).]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Whooah. I've just checked out their web site. I hope you got a better deal than the prices on the site, 'cos if not you were fleeced.
Let this be a lesson to you. Ask here at the 'Ranch before you make that sort of decision. I could suggest several hosting companies who will give you full telnet, cgi, perl, java and even Servlets for around $9.95/month.
Eric Barnhill
Rancher

Joined: Feb 25, 2000
Posts: 233

Thanks, Frank. I was being hosted there long before I found the Ranch. I will email you to get that information, and it will be forwarded to several of my friends who are being hosted there (and similar places).
Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Baby Question
 
Similar Threads
Successful Applet Socket Connection
NodeManager problem
swt application should listen on multiple ports.
Passing argument to use NodeManager
how it is possible??????