Results 1 to 9 of 9
Thread: java and flash
- 04-18-2011, 04:37 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
java and flash
Hi guys, first post, be nice :)
Was just wondering if anyone could tell me how to change the following java server into a multi-threaded one, it has threading capabilities already I believe, so im sure theres something im missing but my java isnt that good:
gruchalski.com » Archive » XMLSocket.send / Socket.writeUTFBytes doesn’t work?
Thanks
Dan
- 04-18-2011, 05:04 PM #2
That's not really how this works. Not many people are going to click on external links, and even fewer people are going to wade through a whole program worth of code.
We can answer specific questions about specific code (in SSCCE form), but general questions like this aren't really answerable.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 04-19-2011, 03:24 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
@KevinWorkman Thanks for the reply, I understand that someone isnt going to wade through a big program and basically do my work for me, I think you misunderstood my request, I was hoping someone could help me with multithreading;
The link I gave is the only working server I have found that correctly serves a policy file to a flash client, but currently it doesnt allow multiple connections from clients.
So I was wondering if someone could help me out with multithreading, in regards to the link I have posted.
But anyway thanks for the reply
Dan
- 04-19-2011, 03:31 PM #4
If I were you, I'd start by reading through this and trying out some simple examples: Lesson: Concurrency (The Java™ Tutorials > Essential Classes)
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 04-20-2011, 06:37 PM #5
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
@KevinWorkman again thanks for the reply, ive read through the link you posted, and believe me when I say ive read through quite a few tutorials etc when trying to sort this out, but no matter what I read or try I can't get it to work.
The link I posted already includes threading capabilities, but i just can't work out how to get it to work, really would appreciate any help here.
Thanks
Dan
- 04-20-2011, 07:04 PM #6
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
The server is already multi-threaded and already accepts multiple clients at a time. Have you tried using it? If so, what issue are you having?
- 04-21-2011, 05:45 PM #7
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
Thanks for the reply @toadaly
The server accepts a connection from one client, and can receive and send data from this client, but if another client connects, the server will only send data received to the sending client, not all clients.
I want the server to receive data from any client and then output it to all clients.
Really appreciate your help
Thanks
Dan
- 04-21-2011, 10:40 PM #8
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Ok. What you need to do then, is create a Set of Socket's. Each time a new client Socket is created, add it to the set. Then create a java.util.BlockingQueue (I'd probably use a simple ArrayBlockingQueue), and a service thread. The service thread will block on queue.take().
When one of the client handler threads receives data, you will call queue.put() with whatever message you're wanting to send to the clients. This will cause the service queue to kick into action. In the service queue, you will loop through the Set of Sockets calling 'getOutputStream' and writing to the output stream. Flush after each write, but do not close the stream.
You must handle exceptions carefully. If the write command throws an exception, then you want to close that socket down (which should cause the associated client thread to throw an exception - which you must handle and return from the thread), and also remove that Socket from the Set.
Good luck!
- 04-27-2011, 12:24 PM #9
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Java add flash object
By Dennis in forum Advanced JavaReplies: 0Last Post: 01-06-2011, 08:06 PM -
Integrating java and flash
By ak88 in forum New To JavaReplies: 1Last Post: 01-18-2010, 03:41 PM -
Java Server, Flash Client
By matbuckland in forum New To JavaReplies: 3Last Post: 09-01-2009, 09:58 AM -
Flash application in Java
By SrihariCh in forum New To JavaReplies: 0Last Post: 03-31-2009, 12:23 PM -
JAVA, Ajax, Flash
By Digital Dispatching in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-06-2008, 07:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks