socket.select problem 
Author Message
 socket.select problem

in the server componet of my app it has multiple clients conencting, so
insted of loads of threads each client socket is put in to an arraylist and
then a clone of this is put in to socket.select in the ready to read field

this works for 1 and 2 clients when it gets to 3 things get weird

3 clients join in order 1, 2, 3,

client 3 cannot say anything to the server
client 2 can say anything he wants to server
client 1 can say only 1 thing to server

i have traced it throuth and found it seems to think client 2 has data to be
read when it doesent.

so
client 3 speaks:
select thinks 2 and 3 have data, it blocks on 2

client 2 speaks:
select thinks client 2 has data and it does

client 1 speaks:
select thinks 1 and 2 have data it handels 1 then blocks on 2.

it never mistakes data in client 2 unless another client has data.

i have checked everythign and can find nothing that would casue this.

so i rewrote the code to use poll insted of select and poll each socket
indevidaly insted then continue as normal if data is found

this works perfectly why?? why does select not work??

this is for an assingment so i need to use select

anyone got any ideas on this??

code bits:

CODE :

//Old Select method does not work!!!

selsockList = (ArrayList)sockList.Clone();

Socket.Select(selsockList, null, null, 1000);

for (int i=0; i < (selsockList.Count); i++)
{
//read
//do stuff

CODE :

//new poll method

for (int i=0; i < (sockList.Count); i++)
{

 if( ((Socket)sockList[i]).Poll(1000, SelectMode.SelectRead) )
 {
    //read
   //do stuff



Sun, 22 May 2005 21:44:26 GMT  
 socket.select problem

Quote:

> in the server componet of my app it has multiple clients conencting, so
> insted of loads of threads each client socket is put in to an arraylist and
> then a clone of this is put in to socket.select in the ready to read field

> this works for 1 and 2 clients when it gets to 3 things get weird

Spike -

    This was an interesting experiment for me. For the Select()
example in my book I just used a two-socket example, which worked just
fine. After reading your post I expanded it to a three socket model.
Sure enough, things went hay-wire, similar to the results you
experienced.

    I tried it out on the .Net 1.1 Framework Beta, and everything
worked fine. I assume that there was a problem with the Select()
method in the 1.0 .Net Framework, which appears to be fixed in the 1.1
Beta.

    If you have to use the Select() method, I suggest downloading the
1.1 Beta and seeing if your code works as expected. Good luck.

Rich Blum
Author of "C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176



Wed, 25 May 2005 04:15:14 GMT  
 socket.select problem

Quote:

> in the server componet of my app it has multiple clients conencting, so
> insted of loads of threads each client socket is put in to an arraylist and
> then a clone of this is put in to socket.select in the ready to read field

> this works for 1 and 2 clients when it gets to 3 things get weird

> 3 clients join in order 1, 2, 3,

> client 3 cannot say anything to the server
> client 2 can say anything he wants to server
> client 1 can say only 1 thing to server

> i have traced it throuth and found it seems to think client 2 has data to be
> read when it doesent.

> so
> client 3 speaks:
> select thinks 2 and 3 have data, it blocks on 2

> client 2 speaks:
> select thinks client 2 has data and it does

> client 1 speaks:
> select thinks 1 and 2 have data it handels 1 then blocks on 2.

> it never mistakes data in client 2 unless another client has data.

> i have checked everythign and can find nothing that would casue this.

> so i rewrote the code to use poll insted of select and poll each socket
> indevidaly insted then continue as normal if data is found

> this works perfectly why?? why does select not work??

> this is for an assingment so i need to use select

> anyone got any ideas on this??

> code bits:

> CODE :

> //Old Select method does not work!!!

> selsockList = (ArrayList)sockList.Clone();

> Socket.Select(selsockList, null, null, 1000);

> for (int i=0; i < (selsockList.Count); i++)
> {
> //read
> //do stuff

> CODE :

> //new poll method

> for (int i=0; i < (sockList.Count); i++)
> {

>  if( ((Socket)sockList[i]).Poll(1000, SelectMode.SelectRead) )
>  {
>     //read
>    //do stuff

Spike, I had same problem with System.Sockets.Socket.Select using managed
C++ program.  I installed 1.1beta of DotNetFramework and the problem
went away.


Tue, 31 May 2005 02:22:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with Socket.Select() method

2. Problem with select() on non-sockets

3. Socket.Select

4. Socket.Select()

5. Stange Socket.Select() behavior

6. Using select() for two sockets

7. socket, select() and accept()

8. Q: select() returns upon socket connection, or STDIN, but not both

9. Sockets select() equivalent for Windows???

10. select, Xevents and sockets

11. sockets and select system call (UNIX)

12. Socket I/O via "select"

 

 
Powered by phpBB® Forum Software