Re: client
heyheyhey wrote:
trying to get a working client to encode name and number, is this right?
There are many problems, many of which will be fixed by adhering to the advice of
<http://www.physci.org/codes/sscce.html>
..
java.io.ObjectOutputStream
This will turn out not to be what you want.
java.io.ByteArrayOutputStream
Ditto - consider just using the socket stream.
public static void main(String args[]){
//creates a string for customers name called Batman
String s= "Batman"
This statement will not compile.
//Converts customer name into byte sequence
byte[] B = S.getBytes("US-ASCII");
Will not compile.
//Creates a string for CC number
String CC= 1212121212121212
Will not compile.
//Convert credit card number into byte sequence
byte[] B =CC;getbytes("US-ASCII");
Will not compile.
//create datagram socket
aSocket = new DatagramSocket();
Is there an class variable called aSocket? If so, that's a bad idea. If not,
this statement will not compile.
//Host name
InetAddress address = InetAddress.getByName("localhost")
Will not compile.
//set port number
public function set ServerPort (3590 : int)
There is no keyword 'function' in Java. Method names should begin with a
lower-case letter. "3590 : int" isn't even remotely Java syntax.
//create datagram packet
DatagramPacket request =
new DatagramPacket(m, args[0].length(), aHost, serverPort);
args[0] and the .length() call on it could throw a RuntimeException.
;
// Send it
aSocket.send(request);
Even assuming you make this into a legitimate call, you still should catch the
potential Exceptions and deal with them appropriately.
--
Lew