Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > socket problem chat?

Reply
Thread Tools

socket problem chat?

 
 
Marc Collin
Guest
Posts: n/a
 
      12-07-2005
hi

i would like to know how in a application client/server how we send received
message to all client?

thanks
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      12-07-2005
Marc Collin <> wrote:
> i would like to know how in a application client/server how we send received
> message to all client?


In general, there are two ways. One is to use multicast. The other is
to individually send the message to each client. Unless you're dealing
with a very large number of clients, it's probably best to do the
latter. Just keep a list of clients, and write a list to send messages
to each one... perhaps each in a different thread to control the delay.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      12-07-2005
On Tue, 06 Dec 2005 23:17:06 -0500, Marc Collin
<> wrote, quoted or indirectly quoted someone
who said :

>i would like to know how in a application client/server how we send received
>message to all client?


Consider using UDP. You can even then have clients send direct to each
other.

see http://mindprod.com/jgloss/udp.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Marc Collin
Guest
Posts: n/a
 
      12-07-2005
Chris Smith wrote:

> Marc Collin <> wrote:
>> i would like to know how in a application client/server how we send
>> received message to all client?

>
> In general, there are two ways. One is to use multicast. The other is
> to individually send the message to each client. Unless you're dealing
> with a very large number of clients, it's probably best to do the
> latter. Just keep a list of clients, and write a list to send messages
> to each one... perhaps each in a different thread to control the delay.
>


ok for the second method but we need to connect to the client
the client need to be a server..
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      12-07-2005
On Wed, 07 Dec 2005 10:59:13 -0500, Marc Collin
<> wrote, quoted or indirectly quoted someone
who said :

>ok for the second method but we need to connect to the client
>the client need to be a server..


Or:
1. UDP
2. every client maintains a socket
3. clients check in with HTTP every "minute" or so to see if there is
a massage.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-07-2005
Marc Collin <> wrote:
> ok for the second method but we need to connect to the client
> the client need to be a server..


When you establish a TCP connection from a client to the server, that
connection is two-way. The server can use it to send data to the
client. That's why java.net.Socket has methods called getInputStream()
and getOutputStream().

If your client disconnect, though, then yes they will need a
ServerSocket to listen for reconnection attempts from the server (and
this is also problematic because many -- or most? -- clients won't have
publicly available ports.)

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
zero
Guest
Posts: n/a
 
      12-07-2005
Chris Smith <> wrote in news:MPG.1e00f21c1bd135c4989c00
@news.altopia.net:

> Marc Collin <> wrote:
>> ok for the second method but we need to connect to the client
>> the client need to be a server..

>
> When you establish a TCP connection from a client to the server, that
> connection is two-way. The server can use it to send data to the
> client. That's why java.net.Socket has methods called getInputStream()
> and getOutputStream().
>
> If your client disconnect, though, then yes they will need a
> ServerSocket to listen for reconnection attempts from the server (and
> this is also problematic because many -- or most? -- clients won't have
> publicly available ports.)
>


Typically it's the client that connects to the server. The server just
sits, waiting for clients to connect. If you need the server to connect to
the client (instead of the other way around) you may want to rethink your
design.

--
Beware the False Authority Syndrome
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57