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.
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
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.
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