• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Communication between client and server

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to run a server side program such that it will run in background and wait for the client message. and at client side i need to send a message to server. and at server depending on the message i got from the client i need to run a piece of code.
I don't know much of socket programming i will be thankful if any one can post a sample code or else any link to the sample code.

thanking you in advance,
Varun Narisetty
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that you are looking for code directly... but I'd recommend you try doing it by yourself.. here are the hints.

1) ServerSocket is a java class which can create a socket (IP/Port combination) in the server, and keep listening for incoming packets.
2) Socket is another java class which can communicate to any other socket or serversocket.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As is so often the case, the Sun Java Tutorial has examples of exactly that. Start reading at http://java.sun.com/docs/books/tutorial/networking/sockets/index.html
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Thammudu ,

you need to follow these steps to see success

1) I think you don't know much of socket programming you will be thankful if any one can post a sample code or else any link to the sample code in formus.
2)you need to run a server side program such that it will run in background like THREADS and wait for the client message.
3)At client side you need to send a message to server through protocals either TCP or UDP/WI-FI
4) At server depending on the message you got from the client you need to run a piece of code in background process.


For code visit www.kickadz.com

Prematho,
Mee muddhula anna
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dawn,
How to establish connection between different machines other than local host through socket programming.

Regards,
Bhavani.G
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vani golakoti wrote:How to establish connection between different machines other than local host through socket programming.


If the method explained in the link I posted doesn't work for you for some reason, then you should tell us *why* that is. It is the standard approach, after all.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic