首页 \ 问答 \ 为什么e.AcceptSocket.ReceiveAsync总是如此(Why e.AcceptSocket.ReceiveAsync alway be true)

为什么e.AcceptSocket.ReceiveAsync总是如此(Why e.AcceptSocket.ReceiveAsync alway be true)

我使用SocketAsyncEventArgs构建了一个小的Socket Server端。 但遇到一些问题,当我接受客户端套接字,然后我尝试使用e.AcceptSocket.ReceiveAsync来接收客户端信息,但我不知道为什么它始终显示为我。 这是服务器端:

    private void ProcessAccept(SocketAsyncEventArgs e)
    {
        Console.WriteLine("Process Accept!");
        if (e.BytesTransferred > 0)
        {
            Console.WriteLine("client online...");
        }

        SocketAsyncEventArgs readEventArgs = new SocketAsyncEventArgs();
        readEventArgs.AcceptSocket = e.AcceptSocket;
        readEventArgs.SetBuffer(new byte[1024], 0, 1024);
        readEventArgs.Completed+=readEventArgsIO_Completed;

        Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
        if (!willRaiseEvent)
        {
            this.ProcessReceive(readEventArgs);
        }

          this.StartAccept(e);
    }

我的客户端只使用Connect方法连接服务器端并向其发送信息“Hello Server”。 但为什么我在这里总是“真实”?

Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);

谢谢。


I used SocketAsyncEventArgs to build a tiny Socket Server side. but encountering some problems, when I accepted the client socket, then I tried to use e.AcceptSocket.ReceiveAsync to receive client side info, but I don't know why it always show True to me. here is the server side:

    private void ProcessAccept(SocketAsyncEventArgs e)
    {
        Console.WriteLine("Process Accept!");
        if (e.BytesTransferred > 0)
        {
            Console.WriteLine("client online...");
        }

        SocketAsyncEventArgs readEventArgs = new SocketAsyncEventArgs();
        readEventArgs.AcceptSocket = e.AcceptSocket;
        readEventArgs.SetBuffer(new byte[1024], 0, 1024);
        readEventArgs.Completed+=readEventArgsIO_Completed;

        Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);
        if (!willRaiseEvent)
        {
            this.ProcessReceive(readEventArgs);
        }

          this.StartAccept(e);
    }

my client side only use the Connect method to connect the server side and send info "Hello Server" to it. but why I am here always got "True"?

Boolean willRaiseEvent = e.AcceptSocket.ReceiveAsync(readEventArgs);

thx.


原文:https://stackoverflow.com/questions/15945261
更新时间:2022-04-17 06:04

最满意答案

计算出水平和垂直分量后,我们有一个实数和一个虚数值(a + bi):

velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1});

如果你想要OpticalFlow值的大小,你只需要计算绝对值,就像在数学中一样:

velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i);


Once you have calculated the Horizontal and Vertical Components, we have a real and an imaginary value (a+bi):

velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1});

If you want the magnitude of the value of the OpticalFlow, you just need to calculate the absolute value, just like in Mathematics:

velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i);

相关问答

更多
  • 跟踪定义了计算机视觉任务,其目标是跟踪给定对象,交互区域或视频序列的连续图像中的点。 一种非常简单的方法将基于通过光流估计方法估计的运动矢量。 然而,这将在非常合作的环境条件下产生良好的结果。 如果对象被遮挡,它将失败。 最新的现有技术方法更加稳健,例如基于卡尔曼滤波器,微粒滤波器或PHD滤波器技术。 关于对象跟踪或对象跟踪的调查:通过调查 ,您可以更好地了解当前对象跟踪方法的挑战和解决方案。 Tracking defines a computer vision task with the goal to ...
  • 2D convolution是这里的方式,正如在问题中预测的那样,以取代那些重mean/average计算。 此外,这些迭代差异可以用MATLAB的diff代替。 因此,结合所有这些,矢量化实施将是 - %// Pad images to handle edge cases img1 = padarray(img1, [1,1], 'post'); img2 = padarray(img2, [1,1], 'post'); %// Store size parameters for later usage ...
  • estimateFlow返回一个opticalFlow对象,该对象具有幅度,相位和速度的属性。 因此,在您的情况下, flow是一个opticalFlow对象,而不是一个复杂的数组,并且您不能将它传递给real和imag 。 而是使用对象的属性: flow.Vx % x component of velocity flow.Vy % y component of velocity flow.Orientation % Phase flow.Magnitude % Ma ...
  • 光流(OF)是围绕所谓的“亮度恒定假设”的方法。 你假设像素 - 更具体,他们的强度(达到一些三角洲) - 不会改变,只会移动。 你找到了这个等式的解:I(x,y,t)= I(x + dx,y + dy,t + dt)。 裁缝系列的第一顺序是:I(x + dx,y + dy,t + dt)= I(x,y,t)+ I_x * dx + I_y * dy + I_t * dt。 然后你解出这个方程,并得到每个像素的dx和dy - 移位。 光流主要用于跟踪和测距 。 upd:如果不应用于整个图像,但补丁,光流几乎 ...
  • 是的,Matlab / C ++: http : //people.csail.mit.edu/celiu/OpticalFlow/ CS UMD EDU: http : //www.cs.umd.edu/~ogale/download/code.html 我通过谷歌搜索发现了更多的参考。 希望有所帮助。 Yes, Matlab/C++: http://people.csail.mit.edu/celiu/OpticalFlow/ CS UMD EDU: http://www.cs.umd.edu/~oga ...
  • Thuis线 cvtColor(frame2, cflow, COLOR_GRAY2BGR); 可能是罪魁祸首。 在上面的一行上,使用frame2 = imread("./car2.jpg", IMREAD_COLOR);加载为彩色图像frame2 = imread("./car2.jpg", IMREAD_COLOR); 但现在你试图将它从灰色转换而来 ,这似乎是不合逻辑的。 Thuis line cvtColor(frame2, cflow, COLOR_GRAY2BGR); is probably ...
  • 有许多光流量基准测试可以获取样品。 最常见的是Middlebury , KITTI2012 / 2015 , SIntel和HAMA数据集/基准。 但是最近的光学流动方法难以应对大的运动,不同的照明和低对比度/纹理。 There are a lot of Optical Flow benchmarks where you can get samples. The most common are Middlebury, the KITTI2012/2015, SIntel and the HAMA datas ...
  • 计算出水平和垂直分量后,我们有一个实数和一个虚数值(a + bi): velocityHx(i) = real(OpticalFlow{i,1}); velocityVy(i) = imag(OpticalFlow{i,1}); 如果你想要OpticalFlow值的大小,你只需要计算绝对值,就像在数学中一样: velocityMagnitudeCentroide(i) = velocityHx(i)*velocityHx(i) + velocityVy(i)*velocityVy(i); Once you ...
  • 我不了解OpenCV,但在这里找到matlab实现。 I dont know about OpenCV, but find matlab implementations here.
  • 在对作者进行了一些挖掘和联系之后,结果发现当向跟踪器提供不同大小的图像时会引起该错误。 容器大小与图像的像素尺寸有关。 就我而言,我相信我的所有图像都具有相同的尺寸,因为它们是裁剪程序的输出。 但是,一些自动裁剪的区域非常接近图像边界,因此裁剪会截断它们,从而导致裁剪区域变小,这里和那里有几个像素。 如果您遇到此错误,这是我要检查的第一件事。 After some more digging and contacting the author, it turns out that this error is ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)