• 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

Hint needed: TCP -> UDP , test on localhost

 
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am to write an EchoClient and an EchoServer. The client should send something to the server with TCP socket. Then the server should echo back the something with UDP socket. Both the user input and the echoed-back would be displayed on client end. This program will be tested on localhost.
I only know how to do it when both the client and server are TCP or UDP. But need some hint about this program. Thank you very much in advance.

Regards,
Ellen
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm failing to understand your question, I think, because I don't see the problem. AFAIK you cannot send datagrams using a Socket, and obviously a DatagramSocket doesn't support TCP/IP, so all you can do is set up a TCP/IP connection for traffic in one direction and a datagram connection in the other.
- Peter
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for having made the question vague. I am trying to make it clearer here: The Echoclient sends some string via a connection-oriented Socket(TCP) to the Echoserver. The Echoserver sends the received string via a connectionless( "Verbingdungslos" in the original question)DatagramSocket(I saw in my class notes that User Datagram Protocol is implemented(realisiert) using Datagram Sockets.) back to the Echoclient. The Echolient should display the sent string as well as the echoed string.
It is suggested to run the client and server on different JVMs. I guess so that I can establish the connections on two different ports? Did you mean that? Thanks again.

Regards,
Ellen
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Server opens ServerSocket on some designated port (new ServerSocket(port1)) and listens (accept()). Client opens DatagramSocket on some designated port (new DatagramSocket(port2)). Client connects to server ServerSocket (new Socket(server, port1)) and sends stuff (getOutputStream(), etc). Server creates a DatagramSocket (new DatagramSocket()) and fires its response as a DatagramPacket at the client.
I still feel I'm missing something.
- Peter
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to Mr. den Haan, here�s the code:
class Echoserver:

class Echoclient


mit freundlichen Gr��en,
Ellen
[ January 28, 2003: Message edited by: Ellen Fu ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic