I'm working on TCP and UDP just to learn the basics of how networks and protocols work in Java, and the task my professor has set me is to have the following:
A TCP Client that connects to a TCP Server, which communicates with a UDP Client that connects to a UDP Server, which gets/alters data from a Database.
I have everything set up and working, but right now the TCP Server calls the UDP Client as an object, and passes its information through a method call, rather than over the internet.
For TCP I'm using server sockets and input stream / buffered stream readers, and for the UDP I'm using datagram packets. So I'm not really sure how I can send from one to the other directly, or if it's even possible.
Thanks in advance for any help/advice/guidance!
Jona
**EDIT:
What I mean by passing through a method call:
//In TCPServer class
UDPClient udpc = new UDPClient();
String result = udpc.GetFromUDPServer(clientCommand);
//In UDPClient class
public class UDPClient{
public String GetFromUDPServer(String clientCommand){
try{
//Create a datagram socket
DatagramSocket sock = new DatagramSocket();
byte[] buffer = clientCommand.getBytes("UTF-8");
InetAddress ipAddress = InetAddress.getByName("localhost");
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, ipAddress, 447);
...