• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Contacting a remote server from the client  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to Java so please forgive me if some of this stuff seems trivial.

I want to contact a remote server program residing in my web space from a local client.  How do I do this ?

I have found this code elsewhere on the internet and it works locally.  When I run the client and server programs
from within Netbeans, they communicate with no problems.  But I want to transfer the server code to the remote
server that hosts my web space and contact it from the client.

Here's some code for the server:


and here's some code for the client:

Any help would be greatly appreciated.

Thanks.

FC.
 
Master Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

transfer the server code to the remote server that hosts my web space and contact it from the client.


Do you have the IP address for that site?  Use that instead of localhost in the client.
 
Pete Bull
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've transferred my server code to the web server but how do I execute the server code on the remote machine so that it waits  for a connection ?

FC.
 
Norm Radder
Master Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

so that it waits  for a connection


The accept method will wait for a connection.

how do I execute the server code on the remote machine


You could do it the same way as on your PC: with the java command.
 
Pete Bull
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've contacted my service provider who informed me that to use Java in this way I need a dedicated or cloud server.

If as you suggest that I can use the java command, where and what do I do with it ?

FC
 
Norm Radder
Master Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java command I referred to is what comes in the JRE which is a free down from Oracle.
It is probably the same program that you used to execute your programs on your PC
 
Pete Bull
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps I should have been more descriptive in my question:

How do I start the server socket program on the remote server, not the local server, running, as it needs to listen for and accept a connection from a client ?

FC
 
Sheriff
Posts: 23714
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like your server provider has some restrictions, or assumptions, about what you can and can't do on your rented server. You might want to have further discussions with them about how to do it -- there's not a lot of point in asking people who don't know anything about the way your server is set up.
 
Norm Radder
Master Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How do I start the server socket program on the remote server


You would use the java command to start the execution of the class.  That is the same command you would use on your PC.  Your server provider would need to help you set it up.
 
Pete Bull
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,

This issue has now been resolved:  In the end I had to change my service provider.  But all your help has been useful and
I'm thankful for it.

Thanks guys.

Pete
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!