This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hint needed: TCP -> UDP , test on localhost

 
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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 ]
 
What's gotten into you? Could it be this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic