当前位置: 代码迷 >> C# >> socket发送文件,等候时间设置
  详细解决方案

socket发送文件,等候时间设置

热度:118   发布时间:2016-05-05 04:45:58.0
socket发送文件,等待时间设置
 if ((socket.Poll(outtime * 10000000, SelectMode.SelectWrite) == true))
                    {
                        senlen = socket.Send(buffer, senlen, left, SocketFlags.None);
                        left -= senlen;
                        if (left == 0)
                        {
                            flag = 0;  //数据发送完毕
                            break;
                        }
                        else
                        {
                            if (senlen > 0)
                            {
                                continue; //数据发送部分
                            }
                            else
                            {
                                flag = -2;  //发送数据发生错误
                                break;
                            }
                        }
                    }
                    else
                    {
                        flag = -1; //超时退出
                        break;
                    }
                }
            }
            catch (SocketException)
            {
                flag = -3;
            }
            return flag;

        }
中等待时间,我必须设置成 10000000,不然发完一个buffer后,直接flag就等于-1了,请问是为什么啊?但时间没等那么久啊
------解决思路----------------------

这都哪抄来的代码。。现在网络上的Socket 代码10有8.9都是不能用的。
------解决思路----------------------
根本看不懂你这是啥逻辑
另外outtime的值是啥
  相关解决方案