Valhalla Legends Forums Archive | Java Programming | Using Sockets

AuthorMessageTime
raylu
I want to write a chatbot in Java (using the ASCII protocol).

I'm kinda new to this, so...

Should I be using a BufferedReader of an InputStream of a Socket to read data?

How do I send data through a Socket for that matter? I could go look it up, but I don't know how to send the protocol byte because I don't know how to use bytes...
June 12, 2005, 5:36 PM
Kp
If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.
June 12, 2005, 8:37 PM
OnlyMeat
[quote author=Kp link=topic=11807.msg115511#msg115511 date=1118608665]
If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.
[/quote]

You are assuming a word is 32 bits.

Machine words are processor specific, for instance on 64 architecture's the word size is 64 bit not 32 bit. Which would make a quarter of a machine word 16 bits not 8.
June 12, 2005, 11:18 PM
The-FooL
Look at the source to JavaOp to see what types of readers/writers you should use for data.  It is important to know that some of the writers/readers/buffered readers will assume text and cause problems with binary protocols.
June 12, 2005, 11:21 PM
Myndfyr
[quote author=The-FooL link=topic=11807.msg115525#msg115525 date=1118618495]
Look at the source to JavaOp to see what types of readers/writers you should use for data.  It is important to know that some of the writers/readers/buffered readers will assume text and cause problems with binary protocols.
[/quote]

Didn't he say he wanted to use the ASCII protocol?

Also, you could probably use something to write to the stream directly rather than using the BufferedWriter to write to the stream to send the protocol byte.

Finally, you can completely ignore OnlyMeat's post, because it has absolutely nothing to do with anything you're trying to accomplish.
June 13, 2005, 12:16 AM
OnlyMeat
[quote author=MyndFyre link=topic=11807.msg115534#msg115534 date=1118621788]
Finally, you can completely ignore OnlyMeat's post, because it has absolutely nothing to do with anything you're trying to accomplish.
[/quote]

It has alot to do with it. The difference between sending 16 bits and 8 bits if you follow kp's post.
June 13, 2005, 1:11 AM
shout
Java uses a VM, so would the VM word sizes not be the same regardless of archiecture? So therefore your post is irrelevant.
June 13, 2005, 1:46 AM
OnlyMeat
[quote author=Shout link=topic=11807.msg115556#msg115556 date=1118627218]
Java uses a VM, so would the VM word sizes not be the same regardless of archiecture?
[/quote]

Your comment contradicts itself. If the word size remains the same it's not a machine word.

Java doesn't explicitly define a word. Instead it has primitive data types which remain a constant size regardless of the architecture. However i believe kp was refering to a machine word which is architecture dependent. I proposed that taking a quarter of a machine word is making assumptions about that architecture.

[quote author=Shout link=topic=11807.msg115556#msg115556 date=1118627218]
So therefore your post is irrelevant.
[/quote]

Seems to me your post is incorrect as well as irrelevant.

June 13, 2005, 2:34 AM
raylu
Well either way, I don't know how to deal with words in Java...I can't even send a measly protocol byte.

I've looked at the JavaOp code, or tried to. There's too much stuff and I don't even know where it sends the protocol byte...
June 13, 2005, 2:50 AM
The-FooL
Look for a sendbyte or sendchar method.
June 13, 2005, 3:41 AM
R.a.B.B.i.T
out.write((char) 3);
out.flush();
June 13, 2005, 3:49 AM
Tuberload
I would suggest learning how to use the Java language, understanding its data types, and figuring out everything else needed to make a bot before you actually try. Grab a book, read a tutorial, or download the manual. One way or another I am sure you shall succeed.
June 13, 2005, 6:56 AM
kamakazie
[quote author=OnlyMeat link=topic=11807.msg115524#msg115524 date=1118618309]
[quote author=Kp link=topic=11807.msg115511#msg115511 date=1118608665]
If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.
[/quote]

You are assuming a word is 32 bits.

Machine words are processor specific, for instance on 64 architecture's the word size is 64 bit not 32 bit. Which would make a quarter of a machine word 16 bits not 8.
[/quote]

Kp's post doesn't sound very serious...but in any case, you're getting off-topic because we're on the subject of Java for which there is a big abstraction from processor specifics, like Shout mentions yet you refute.
June 13, 2005, 2:41 PM
Kp
Although it seems OnlyMeat was the only one who didn't understand this: my post was facetious, though it did also offer useful advice (master bytes).
June 14, 2005, 2:22 AM

Search