Hey, I need a little help with my socket-ing
Here's the general idea:
PHP Code:[STAThreadAttribute] static int Main()
{
TcpListener sckMain = new TcpListener(6485);
bool bClose = false;
//...
sckMain.Start();
while(true) //and loop for a while.
{
if (sckMain.Pending()) //pending connection!
{
Socket sckOut = sckMain.AcceptSocket();
while(sckOut.Connected) //Get data while we're still connected...
{
if (sckOut.Available > 0) //is there data to read?
{
//.......
}
}
Thread.Sleep(10);
if(bClose){ return 0; }
}
Thread.Sleep(500);
}
The problem is that if I disconnect and reconnect, I will connect, but my commands are never processed -- because sckOut.Connected seems to always return true. Can anyone point me in the right direction?




Reply With Quote