使用TcpListener和tcpClient进行套接字编程 [英] Socket programming using TcpListener and tcpClient

查看:101
本文介绍了使用TcpListener和tcpClient进行套接字编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

顺应端口上可用的字节数.
当我们打电话给

Hello,

supose there crore of byte avalable on a port.
when we call

_client.Client.BeginReceive(_recieveBuffer, 0, 1024, SocketFlags.None, new AsyncCallback(OnBytesRecieved), null);


然后我们说


and after it we say

_client.Client.EndRecieve()


然后我们将一些字节存储在_recievBuffer中,可以了.

现在,如果下次再次调用


then we get some bytes stored in _recievBuffer its ok

now if next time again calling

_client.Client.BeginReceive(_recieveBuffer, 0, 1024, SocketFlags.None, new AsyncCallback(OnBytesRecieved), null);


TcpClient.Endrecieve()


所以无论我们收到了什么,我都可以再次获得相同的数据吗???
还是从头开始读取,并且在每个接收指针都移到下一个之后??


so here againt may i get same data whatever we have recieved?????
or it stars reading from beginning and after each recieve pointer moved next??

推荐答案



我认为有关CodeProject的这篇文章可以为您提供帮助:
使用C#的TCP/IP聊天应用程序 [
Hi,

I think this article on CodeProject can help you:
TCP/IP Chat Application Using C#[^]

It''s an article about network programming.


这篇关于使用TcpListener和tcpClient进行套接字编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆