• Welcome to Valhalla Legends Archive.
 

Using Sockets

Started by raylu, June 12, 2005, 12:36 PM

Previous topic - Next topic

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...
Pie?

Kp

If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

OnlyMeat

#2
Quote from: Kp on June 12, 2005, 03:37 PM
If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.

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.

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.

MyndFyre

#4
Quote from: The-FooL on June 12, 2005, 06:21 PM
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.

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

OnlyMeat

Quote from: MyndFyre on June 12, 2005, 07:16 PM
Finally, you can completely ignore OnlyMeat's post, because it has absolutely nothing to do with anything you're trying to accomplish.

It has alot to do with it. The difference between sending 16 bits and 8 bits if you follow kp's post.

shout

Java uses a VM, so would the VM word sizes not be the same regardless of archiecture? So therefore your post is irrelevant.

OnlyMeat

Quote from: Shout on June 12, 2005, 08:46 PM
Java uses a VM, so would the VM word sizes not be the same regardless of archiecture?

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 from: Shout on June 12, 2005, 08:46 PM
So therefore your post is irrelevant.

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


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...
Pie?

The-FooL

Look for a sendbyte or sendchar method.

R.a.B.B.i.T

out.write((char) 3);
out.flush();

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.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

dxoigmn

#12
Quote from: OnlyMeat on June 12, 2005, 06:18 PM
Quote from: Kp on June 12, 2005, 03:37 PM
If you know how to send words, you can just send a quarter-word instead.  Otherwise, I suggest you master bytes.

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.

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.

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).
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!