473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Socket::Select problem

Hi guys,
I have just a problem with the Select timeout parameter.
The MSDN tells us:
microSeconds
The time-out value, in microseconds. A -1 value indicates an infinite
time-out.

I try to use -1 as timeout value but the select returns immediately.
That's correct if, at least, one of the list passed to the select has count
property 0.
But that's not happening to me.

Is it a bug? Did I make any kind of errors?
Someone seems to have the same problem using C#:
http://groups.google.it/group/micros...a02804279079e3

Thanks in advance.
Sektor.

Following the code used (it's like a proxy):
// Waiting for a connection
Socket^ fromClient = _accept(); // TcpListener, Start, AcceptSocket
// Create a connection to the server
TcpClient^ toServer = gcnew TcpClient();
toServer->Connect(ServerName, ServerPort);

//These work well
//bool b1 = fromClient->Poll(-1, SelectMode::SelectRead);
//bool b2 = toServer->Client->Poll(-1, SelectMode::SelectRead);

ArrayList^ checkRead = gcnew ArrayList();
array<Byte>^ buf = gcnew array<Byte>(DEFAULT_BUF_SIZE);

int n = 0;
bool toBeClose = false;
// Forward data
while (1) {
checkRead->Add(fromClient);
checkRead->Add(toServer->Client);
try {
Socket::Select(checkRead, nullptr, nullptr, -1);
for each (Socket^ s in checkRead) {
n = s->Receive(buf);
if (n <= 0) {
toBeClose = true;
break;
}
Array::Resize(buf, n);
Byte prx;
if (s->Equals(fromClient)) {
toServer->GetStream()->Write(buf, 0, n);
} else {
fromClient->Send(buf);
}
Array::Resize(buf, DEFAULT_BUF_SIZE);
}
} catch (SocketException^ e) {
Console::WriteLine("Sockets closed");
Console::WriteLine(e->ToString());
return;
}
checkRead->Clear();
if (toBeClose)
break;
}

Sep 5 '06 #1
0 963

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dario | last post by:
I have an unmanaged library that handle many TCP/IP connections. In my .NET application i want to test if there is input available on these connections. Using an existing function of the unmanaged...
1
by: dexter15820 | last post by:
I am having a socket problem after upgrading my .net framework 1.1 to the latest patch level. After the upgrade I can establish a connection but I cannot read from the socket. If I remove the...
1
by: osaleh | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manupilate the FD_SetSize to...
0
by: Markus S. | last post by:
Hello! I have two questions about Socket.Select(): 1) How is it possible to interrupt Socket.Select()? I'm calling Socket.Select() in a worker thread. When new sockets are added (from another...
2
by: yaron | last post by:
i get an SocketException exception when using socket select method. how do i know what is the socket that cause the exception ? can i get this info from the exception instance ? Thanks.
9
by: Stuart | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manipulate the FD_SetSize to...
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
6
by: Dilip | last post by:
I don't know how I missed this piece for so long (this may also be old news to you guys) but in this ACMQueue article, Michi Henning goes to elaborate lengths to detail how even today designing a...
16
by: =?iso-8859-1?q?|-|e|=5F|=5F_B0=DD?= | last post by:
hi all! I got a problem. I declared a SOCKET var in my C program but when i compiled the program it displayed like *--------------------------------------------------------------* *'SOCKET':...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.