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
.



Relevant Pages

  • Re: What is going on in this newsgroup?
    ... or is it Adam West as Batman. ... Definately a Shatner. ... A-Dub would real off a string of words, then, ...
    (alt.guitar)
  • Re: if statements with multiple returns
    ... Assuming that the string of interest is in A2 and the list of specific ... Batman wrote: ... I'm trying to find and return specific text (the 14th and 15th character) ... can someone provide a formula that could return only these 2 values, and i should be ok to replicate it from there?? ...
    (microsoft.public.excel.worksheet.functions)