Multiple Socket Manipulation 
Author Message
 Multiple Socket Manipulation

Hey all, I'm writing a chat application, and I have a computer to
spare (windows). So I figured I would use my windows computer as a
server, and then I would have people connect to it, kind of like AIM.

What I didn't know it how many pit-falls I would encounter.

I am new to REALbasic, but have been using Visual Basic for some time.
I am still in the beginner level of RB or VB. I have recived some code
from other people that allow me to create my own sockets when someone
connects, therefor letting my have multiple connections. One problem.
I don't know how to manipulate all of my sockets at once!

I want to beable to send a command to every one of my sockets at once.
and
I want to beable to send a command to all of the sockets that happen
to be connected to a client.

Please help me do these two things!!

Thanks,

Luke



Sun, 26 Sep 2004 05:53:08 GMT  
 Multiple Socket Manipulation
On 9/4/02 10:53 pm, in article

Quote:

> Hey all, I'm writing a chat application, and I have a computer to
> spare (windows). So I figured I would use my windows computer as a
> server, and then I would have people connect to it, kind of like AIM.

> What I didn't know it how many pit-falls I would encounter.

> I am new to REALbasic, but have been using Visual Basic for some time.
> I am still in the beginner level of RB or VB. I have recived some code
> from other people that allow me to create my own sockets when someone
> connects, therefor letting my have multiple connections. One problem.
> I don't know how to manipulate all of my sockets at once!

> I want to beable to send a command to every one of my sockets at once.
> and
> I want to beable to send a command to all of the sockets that happen
> to be connected to a client.

> Please help me do these two things!!

> Thanks,

> Luke

They way to do this is to create a global property (connectioncount as
integer), then in the connected event of the socket put ConnectionCount =
ConnectionCount + 1, and in the error event:

If me.lasterrorcode = 102 then
ConnectionCount = ConnectionCount - 1
End if

Then to send data to all connected users:

Dim I as integer
If ConnectionCount > -1 then
For I = 0 to ConnectionCount - 1
MySocket(i).write "bla bla"
Next
End if

And that's it. This way assumes you have multiple connected users using the
same socket object with a index value, which is the way I have done it in
the past.

Hope this helps you.

Regards.
--------
Chris Willis



Sun, 26 Sep 2004 22:32:39 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Multiple connection with one socket?

2. Multiple sockets question

3. How do I set-up Multiple socket connections

4. TCL multiple sockets communication

5. Multiple Sockets

6. Sockets, callbacks and multiple clients

7. OO design and multiple local sockets

8. Opening sockets on multiple ports

9. multiple sockets question...

10. Multiple Socket Connections

11. Help for Key Bindings/Socket Communication/Multiple Window Management

12. socket problems under windows: cannot load Socket.so under windows

 

 
Powered by phpBB® Forum Software