Results 1 to 7 of 7
Thread: protocol questions
- 12-20-2011, 10:10 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 34
- Rep Power
- 0
- 12-20-2011, 11:09 PM #2
Re: protocol questions
There are several classes in the java.net package you will need to use to create your own protocol for a URL.
Can you explain how you plan to use this protocol?
- 12-20-2011, 11:15 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 34
- Rep Power
- 0
Re: protocol questions
I need an applet to be able to send data over this protocol and get some responses from a jar file.
- 12-20-2011, 11:19 PM #4
Re: protocol questions
Can you define what you want to do?
I assume you are looking for a simple way for two programs to communicate over an internet connection.
List all the types of messages each program can send to the other. Assign an id of some kind and define the contents of the rest of the message that is to be sent.
- 12-20-2011, 11:37 PM #5
Member
- Join Date
- Dec 2011
- Posts
- 34
- Rep Power
- 0
Re: protocol questions
yes, I am trying to get an applet to talk with a jar, and pass info for a chat log. I need ten functions:
1. Login {username} {password} - Boolean if user is logged in and int ID response
2. getMessages {ID}- array of messages response
3. sendMessage {message} {ID} - Boolean response whether it worked
4. logout {ID} - Boolean if user is logged out response
5. ban {ID} {BannedID} - Boolean response if succeeded
6. unban {ID} {unbandID} - Boolean response if succeeded
7. mute {ID} {MuteID} - Boolean response if succeeded
8. unmute {ID} {unmuteID} - Boolean response if succeeded
9. op {ID} {newopID} - Boolean response if succeeded
10. de-op {ID} {de-oppedID} - Boolean response if succeeded
all {} are just variablesLast edited by jobud9; 12-20-2011 at 11:45 PM.
- 12-20-2011, 11:57 PM #6
Re: protocol questions
Make a single byte id for each of the functions.
For the variable length parts of each message you can either send prefix lengths for each of the message's parts or add a delimiter after each part of the message.
- 12-21-2011, 03:34 AM #7
Re: protocol questions
Has anyone suggested object serialization? I don't know the core requirements of the 'protocol' but the quickest and simplest way I've always used for network based app to app or client to server communication was object serialization. The idea is this: Write a java object that represents a message. You can even use enumerated types or subclassing or both to allow different types of messages to be used. Include fields for all the commands or data bits you need (strings, booleans, ints, enums, whatever). Then, just open a socket, and send the object through. On the other end, you can read the object just like any other java object and grab whatever properties you need. I wrote a network chess system once that paired players using a centralized server. The communication object was something like this:
ComMessage
+ type: enum (SIGN_ON, DISCONNECT, MOVE, MESSAGE)
+ username: String
+ source: Point
+ dest: Point
+ message: String
Based on the enum type, I knew which fields to pay attention to, the rest of the fields would be null. This object held all the data I needed to send chess moves, login commands and usernames, chat client messages, etc...
Look at the ObjectOutputStream and it's corresponding ObjectInputStream.
There might be lower overhead protocols, but with efficiency comes effort. I implemented TCP/IP from scratch once in java... argh. Bit shifting is fast, and binary headers are lean, but it was a LOT of work (in java).
Similar Threads
-
network protocol
By passer-by in forum NetworkingReplies: 0Last Post: 08-09-2011, 08:35 AM -
unsupported protocol
By shiva in forum New To JavaReplies: 1Last Post: 04-09-2009, 09:20 AM -
x modem protocol
By jithan in forum New To JavaReplies: 0Last Post: 08-21-2008, 10:43 AM -
New Protocol?
By lada.r in forum NetworkingReplies: 0Last Post: 11-06-2007, 09:13 PM -
how to use SIP protocol
By katie in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 10:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks