Mensen, ik kom er niet uit. Zijn er hier slimmerikken die dit wel weten?
code:
// Client.java: The client sends the input to the server and receives
// result back from the server
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Client {
{
// Main method
public static void main(String[] args)
{
try
{
// Create a socket to connect to the server
Socket connectToServer = new Socket("localhost", 8000);
// Create an input stream to receive data from the server
ObjectInputStream isFromServer = new ObjectInputStream(
connectToServer.getInputStream());
// Create an output stream to send data to the server
ObjectOutputStream osToServer =
new ObjectOutputStream(connectToServer.getOutputStream());
// Continuously send radius and receive area from the server
while (true)
{
// Read the radius from the keyboard
System.out.print("Please enter a code: ");
String code = MyInput.readObject();
// Send the radius to the server
osToServer.writeObject(code);
osToServer.flush();
// Get area from the server
String terug = isFromServer.readObject();
// Print area on the console
System.out.println("code received from the server is "
+ terug);
}
}
catch (IOException ex)
{
System.err.println(ex);
}
}
}
Fout:
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:12: illegal start of expression
public static void main(String[] args)
^
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:51: ';' expected
}
^
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:52: '}' expected
}
^
3 errors
Tool completed with exit code 1
code:
// Client.java: The client sends the input to the server and receives
// result back from the server
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Client {
{
// Main method
public static void main(String[] args)
{
try
{
// Create a socket to connect to the server
Socket connectToServer = new Socket("localhost", 8000);
// Create an input stream to receive data from the server
ObjectInputStream isFromServer = new ObjectInputStream(
connectToServer.getInputStream());
// Create an output stream to send data to the server
ObjectOutputStream osToServer =
new ObjectOutputStream(connectToServer.getOutputStream());
// Continuously send radius and receive area from the server
while (true)
{
// Read the radius from the keyboard
System.out.print("Please enter a code: ");
String code = MyInput.readObject();
// Send the radius to the server
osToServer.writeObject(code);
osToServer.flush();
// Get area from the server
String terug = isFromServer.readObject();
// Print area on the console
System.out.println("code received from the server is "
+ terug);
}
}
catch (IOException ex)
{
System.err.println(ex);
}
}
}
Fout:
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:12: illegal start of expression
public static void main(String[] args)
^
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:51: ';' expected
}
^
C:\Documents and Settings\Out10\Desktop\Tentamen4Java\ITassesment\Client.java:52: '}' expected
}
^
3 errors
Tool completed with exit code 1
No Signature