组播问题,MulticastSocket接收信息时被阻塞,为何接收不到数据呢? [问题点数:20分]

Bbs1
本版专家分:51
结帖率 98.47%
Bbs1
本版专家分:17
Bbs1
本版专家分:51
Bbs1
本版专家分:0
组播数据接收问题
我用Select模型<em>接收</em>网络<em>组播</em><em>数据</em>。网络<em>数据</em>发送比较慢时,一切正常;但是<em>组播</em><em>数据</em>发送比较块时,<em>接收</em>端<em>接收</em>几个<em>数据</em>包后就在再也收<em>不到</em><em>数据</em>了。不知有谁遇到过该<em>问题</em>,可否指点一二,不胜感激!!!!!!!!!!!!!(<em>接收</em>端是Win2000,发送端是VxWorks)
关于Android中接收不到组播信息
最近在做局域网内群组短消息功能时,发现有的设备不能<em>接收</em><em>组播</em><em>信息</em>,或者亮屏的时候可以<em>接收</em><em>组播</em>消息,灭屏之后却<em>接收</em><em>不到</em><em>组播</em><em>信息</em>,在网上找了很多资代码料,都说要Android为了省电把<em>接收</em><em>组播</em>关了要手动打开,参考如下前辈的博客: http://blog.csdn.net/cxlmax/article/details/7864993 要想打开<em>组播</em>功能,有以下几个步骤: 在Ma
怎么接收不到信息呢?
点击对话框的发送按钮,发送一个<em>信息</em>,怎么就<em>接收</em><em>不到</em>呢?rn[code=C/C++]rn#define WM_SENDBATCH WM_USER + 23rnclass CUSBLabDlg : public CDialogrnrn....rnrnvoid CUSBLabDlg::OnButtonSend() //按钮事件rnrn // TODO: Add your control notification handler code herern UpdateData(true);rn if(!m_EditMsg.IsEmpty())rn rn WPARAM wParam;rn wParam = (WPARAM)(m_EditMsg.GetBuffer(m_EditMsg.GetLength()));rn m_EditMsg.ReleaseBuffer();rn SendMessage(WM_SENDBATCH, wParam, m_EditMsg.GetLength());//发送<em>信息</em>rn m_EditMsg = "";rn UpdateData(false);rn rnrnrnclass CMainFrame : public CFrameWndrnrn......rnprotected:rnafx_msg void OnSendBatch(WPARAM wParam, LPARAM lParam);rnrnrnBEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)rn//AFX_MSG_MAP(CMainFrame)rnON_MESSAGE(WM_SENDBATCH, OnSendBatch)rn//AFX_MSG_MAPrnEND_MESSAGE_MAP()rnrnvoid OnSendBatch(WPARAM wParam, LPARAM lParam)rnrn AfxMessageBox("Hello");rnrn[/code]rnrn
接收不到本机发送的组播数据
我有一个程序,分服务器和客户机两部分,服务器以<em>组播</em>的方式向某<em>组播</em>地址发送<em>数据</em>,客户端在这个<em>组播</em>地址上<em>接收</em><em>数据</em>。我在单位调试时,单位是一个局域网环境,将服务器端程序和客户端程序在一台机子上运行,客户端可以<em>接收</em>到<em>数据</em>;可我在家里调试却不行,家里是小区宽带。各位大虾指点一下,家里的机子怎么无法<em>接收</em>本机发送的<em>组播</em><em>数据</em>?(帮我解决<em>问题</em>的大虾才给分)
组播数据本机可以接收,其他机就接收不到
如题。是为什么?rn谢谢!
关于数据组播接收问题
程序要求很简单服务器发送<em>数据</em>客户端<em>接收</em>。现在看了好多代码 有一些用WSAAsyncSelect第4个参数设置成FD_READ实现,rn有一些用继承CSocket的OnRecieve来实现。请问这两种有合区别?哪个好些?
socket.Receive 接收 阻塞 数据问题
代码:rnwhile(连接中) rn byte[] data = new byte[1024];rn len = socket.Receive(data, data.Length, SocketFlags.None);rn if(len > 0) rn // 收到<em>数据</em>,处理rn rnrnrn情况:rnrn当客户端是多线程发送消息时候,多线程同一时刻都发送消息的话【消息长度小于1024】,rnrnReceive<em>接收</em>到<em>数据</em>,就会把多个线程的消息拼接到一起,直到byte[1024]满了,才出来。rnrn如何处理?才能接到1个线程消息就退出<em>阻塞</em>,然继续<em>接收</em>下个消息
接收udp组播信息的方法
1、使用recvfrom<em>接收</em> SOCKET socket1; //InitWinsock(); WSADATA wsaData; int iErrorCode; if (WSAStartup(MAKEWORD(2,1),&wsaData)) //调用Windows Sockets DLL { printf("Winsock无
为何接收不到jquery参数呢
222.htmlrn[code=javascript]rn$.ajax(rn type: "POST", rn contentType: "application/json", rn url: "222.asp", rn data: "id":"123", rn dataType: 'json', rn success: function(result) rn alert(result.msg);rn rn );rn[/code]rnrn222.asprn[code=javascript]rnrn[/code]rnrn<em>为何</em>222.asp<em>接收</em><em>不到</em>id的值呢。
SJA1000接收不到信息接收中断也不能被触发
我用的是BasicCAN模式,1/2分频(Intel)。rn初始化程序貌似没有<em>问题</em>,我在初始化之后读了寄存器的值:控制寄存器(0x00):0x3e;状态寄存器(0x02):0x0c;中断控制寄存器(0x03):0xe0。rn但是在<em>信息</em>发送之后读状态还是0x0c,不知道是发送成功了吗?这样显示感觉就是成功的,然后我在后面加上<em>接收</em>的命令,结果这个状态一直都没变过,<em>接收</em>的状态和中断都没有变化,而且如果发送成功之后,发送中断也应该是被触发的是吗?也没有出现过,不知道何原因;rn我的CPU初始化如下:rn SCON = 0x50; //UART模式1rn TMOD = 0x20; //定时器1工作模式2,八位自动重装rn PCON = 0x00;rn TH1 = 0xfd;rn TR1 = 1;//启动定时器1rn ES = 0;rnrn EA =1;rn EX0 =1;//外部中断0中断允许位rn PX0 =1;//外部中断0优先级控制位rn我这里是用了串口发送<em>信息</em>的,为了看那些值,所以串口也初始化了,不知道有没有哪些地方没考虑到。rn希望路过的朋友们帮忙解答,谢谢了!
为何接收不到Com2发出的数据???
在使用串口通讯时,Com2口无法<em>接收</em>,但是可以通过该Com口发送<em>数据</em>,即函数OnOnCommMscomm2()没有被执行,rnrn但是Com1可以,在我的程序中两个Com都要用到,
嵌入式linux 组播接收问题
我的板子用嵌入式linux系统发送<em>组播</em>包给我PC虚拟机的linux,虚拟机的linux可以<em>接收</em>到,但是同样的程序,用虚拟机的linux发送,嵌入式linux却<em>接收</em><em>不到</em>,具体表现为<em>阻塞</em>在recvfrom函数。rn大致已经可以排除的<em>问题</em>:rn1、网络、交换机等<em>问题</em>,2台设备之间直接用网线相连,不经过任何中间设备。rn2、嵌入式linux内核<em>问题</em>,内核编译时我已经选上支持multicast,而且嵌入式linux能发出<em>组播</em>包说明内核起码在一定程度上肯定支持<em>组播</em>了。rn从网上也找到了好多解决<em>问题</em>的方法,但都没彻底解决:rnrn测试代码没<em>问题</em>,防火墙关闭,内核已经支持,路由也加了。rnrn请问如何解决?
linux下组播接收问题
我写了一个linux下<em>接收</em><em>组播</em>的代码,但是收<em>不到</em>东西,不知道什么地方错了.本地的IP地址是188.1.34.48,<em>组播</em>地址224.2.2.2,<em>组播</em>发送端口6666,<em>组播</em>发送没有<em>问题</em>,我在windows下写的程序就可以收到.rn#include rn#include rn#include rn#include rn#include rn#include rn#include rn#define BUFLEN 255rnint main(int argc, char* argv[])rnrn struct sockaddr_in localaddr, fromaddr ;rn struct ip_mreq mcaddr ;rn int sockfd, n ;rn unsigned int len ;rn char msg[BUFLEN + 1] ;rnrn sockfd = socket(AF_INET, SOCK_DGRAM, 0) ;rn if (sockfd < 0)rn rn printf("socket creating error\n") ;rn exit(1) ;rn rnrn memset(&localaddr, 0x0, sizeof(struct sockaddr_in)) ;rn localaddr.sin_family = AF_INET ;rn localaddr.sin_port = htons(6666) ;rn if (inet_pton(AF_INET, "188.1.34.48", &localaddr.sin_addr) < 0)rn rn printf("bind error\n") ;rn exit(2) ;rn rnrn if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcaddr, sizeof(struct ip_mreq)) < 0)rn rn printf("setsockop error, join multicast failed\n") ;rn exit(4) ;rn rnrn len = sizeof(struct sockaddr_in) ;rnrn while (true)rn rn //n = read(sockfd, msg, BUFLEN) ;rn printf("ee\n") ;rnrn n = recvfrom(sockfd, msg, BUFLEN, 0, (sockaddr *)&fromaddr, &len) ;rn printf("Datagram from received\n", inet_ntoa(fromaddr.sin_addr), ntohs(fromaddr.sin_port)) ;rn if (n == -1)rn rn printf("recvfrom error\n") ;rn exit(3) ;rn rn elsern rn msg[n] = 0x0 ;rn printf("%s", msg) ;rn rn printf("aa\n") ;rn rn system("pause") ;rn return 0 ;rn
多网卡接收组播问题
我的<em>问题</em>跟下面这个链接的<em>问题</em>完全一样,但下面这个链接没有满意答案, 谁来帮我解答这个<em>问题</em>?rnrnhttp://topic.csdn.net/u/20070520/21/f798b848-997f-4d8e-9084-4d496cc9eec3.htmlrnrn有两个网卡,有时可以有时不可以从第二个网卡收到<em>组播</em><em>数据</em>, OS是RHEL 5
双网卡接收组播问题
机器上有两个网卡,分别接到了不同的网络中(其实是一个接到了交换机上,另一个直接用网线连到了笔记本上)rn然后用笔记本发送<em>组播</em>rnrnipmreq.imr_interface.S_un.S_addr = INADDR_ANY;rnipmreq.imr_multiaddr.S_un.S_addr = inet_addr("235.0.0.1");rnnRet = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *) &ipmreq, sizeof(ipmreq));rnrn如果像上面一样imr_interface指定的是INADDR_ANY的话,程序收<em>不到</em><em>组播</em><em>数据</em>rn改成 ipmreq.imr_interface.S_un.S_addr = inet_addr("192.168.10.11");后才能正常<em>接收</em><em>组播</em><em>数据</em>(192.168.10.11是跟笔记本直连的网口的ip地址)rnrn有没有什么办法不指定具体的网卡,使用INADDR_ANY就能直<em>接收</em>到所有网口上的<em>组播</em><em>数据</em>呢,因为有时候不确定<em>组播</em><em>数据</em>时从哪个网口上过来的rnrn
关于组播接收问题
流程:本机发送一个搜索命令到<em>组播</em>里面去。然后<em>组播</em>里的机器收到我发的命令之后。先发送一条反馈命令。立马接着发送关于IPC的<em>数据</em><em>信息</em>。rn<em>问题</em>:我这边<em>接收</em>的时候有时会出现乱码,或者<em>接收</em>不全,有时全部<em>接收</em>正常。但是通过抓包工具查看,是所有设备都有响应。发送的<em>数据</em>也正常。rn请问一下,这些原因会是什么呢。需要<em>接收</em>源码的话,我可以贴出来。
NMUDP接收不到数据
我现在用NMPUDP实现一个UDP小程序,发送程序可以实现,但是<em>接收</em><em>不到</em><em>数据</em>,<em>接收</em>事件是通过NMUDP1DataReceived实现的,但是<em>接收</em><em>不到</em><em>数据</em>的<em>问题</em>出现了,用断点调试,发现程序根本不执行该函数内容,这是为什么呢?谁来帮忙解决下啊。。。灰常感谢
at指令接收不到数据
过程状态如下:rn 使用超级终端能够和手机正常通讯,发送:at,返回:OK, 关闭睡眠:at+eslp=0其他通用指令都能使用。然后关闭超级终端,重启手机,用自己的程序打开串口,发送指令,都能<em>接收</em>得到。关闭程序,重启手机几次后,用自己的程序和手机执行以上命令,都正常返回。rn int Init()rn rn char ans[128]=0; // 应答串rnrn // 测试GSM-MODEM的存在性rn WriteComm("AT\r", 3);rn ReadComm(ans, 128);rnrn if (strstr(ans, "OK") == NULL)rn rn return 0;rn rnrn //AT+ESLP=0 关闭睡眠rn WriteComm("AT+ESLP=0\r", 10);rn ReadComm(ans, 128); rn rnrn int WriteComm(void* pData, int nLength)rn rn DWORD dwNumWrite; // 串口发出的<em>数据</em>长度rn WriteFile(hComm, pData, (DWORD)nLength, &dwNumWrite, NULL);rn return (int)dwNumWrite;rn rnrn int ReadComm(void* pData, int nLength)rn rn DWORD dwNumRead; // 串口收到的<em>数据</em>长度rn ReadFile(hComm, pData, (DWORD)nLength, &dwNumRead, NULL); rn return (int)dwNumRead;rn rnrn 拔掉<em>数据</em>线,重新插入。开启自己的程序,连接手机,打开串口,发送指令。此时<em>接收</em><em>不到</em>任何应答<em>数据</em>。rn不知道<em>为何</em>?rn rnrn rn rn
jrtp接收不到数据
这是我的<em>接收</em>端的源代码:[code=css]#include "rtpsession.h"rn#include "rtppacket.h"rn#include "rtpudpv4transmitter.h"rn#include "rtpipv4address.h"rn#include "rtpsessionparams.h"rn#include "rtperrors.h"rn#include rn#include rn#include rn#include rn#include rn#include rnrn#include "rtpsourcedata.h"rnrnclass MyRTPSession : public RTPSessionrnrnprotected:rn void OnPollThreadStep();rn void ProcessRTPPacket(const RTPSourceData &srcdat,const RTPPacket &rtppack);rn;rnrnvoid MyRTPSession::OnPollThreadStep()rnrn BeginDataAccess();rn // check incoming packetsrn if (GotoFirstSourceWithData())rn rn dorn rn RTPPacket *pack;rn RTPSourceData *srcdat;rn rn srcdat = GetCurrentSourceInfo();rn rn while ((pack = GetNextPacket()) != NULL)rn rn rn ProcessRTPPacket(*srcdat,*pack);rn DeletePacket(pack);rn rn while (GotoNextSourceWithData());rn rn rn EndDataAccess();rnrnrnvoid MyRTPSession::ProcessRTPPacket(const RTPSourceData &srcdat,const RTPPacket &rtppack)rnrn printf("got packet!\n");rnrnrnint main()rnrn MyRTPSession sessrecv;rn short portbase;rn std::string ipstr;rn int status,num;rnrn // First, we'll ask for the necessary informationrn rn portbase=8020;rn num=10;rn int i;rn RTPUDPv4TransmissionParams transparams;rn RTPSessionParams sessparams;rn sessparams.SetOwnTimestampUnit(1.0/8000.0); rn rn transparams.SetPortbase(portbase);rn status = sessrecv.Create(sessparams,&transparams); rn checkerror(status);rn rn // Wait a number of secondsrn for(i=0;i
为何接收不到键盘消息?
我从CWnd派生了一个新类,但<em>为何</em><em>接收</em><em>不到</em>键盘消息?
Receive()接收不到数据
出<em>问题</em>的程序段如下:rnwhile(!bExit)rnrn // 等待主线程传来Accept生成的socket值rn ::WaitForSingleObject(MyView->ReceiveStart.m_hObject, INFINITE);rnrn // 准备开始互斥完成工作rn if (localLock->Lock(0)) rn rn MyView->ReceiveStart.ResetEvent();rn recvSocket.Attach(MyView->m_RecvSocket);// 获得当前这个socketrn MyView->AcceptNow.SetEvent(); rn localLock->Unlock(); // 解锁rn recvdSize = recvSocket.Receive((char*)&recved_pkt, sizeof(PKT));rn if (recvdSize == SOCKET_ERROR) ;rn elsern ;rnrn说明:MyView是指向View的指针,m_RecvSocket是一个View的成员变量,保存Accept时生成的socket,其它一些是CEvent的对象,用来完成线程间同步。rnrnrn每次recvdSize都是SOCKET_ERROR, 即使其中那句“recvSocket.Attach(MyView->m_RecvSocket)”(对Attach()我的理解不太深)改成recvSocket.m_hSocket = MyView->m_RecvSocket.m_hSocket, 也会报错,错误编号10038(WSAENOTSOCK)。真是摸不着头脑,希望有行家能给我解答一下。rnrn多谢多谢!!
网络编程,接收不到数据
刚开始学网络编程,写了个小程序测试了一下,老是第一次<em>接收</em><em>不到</em><em>数据</em>,但是就是能<em>接收</em>到结束标志,郁闷。rn一小段代码如下:rnrn 服务端: while(1)rn rn printf("abc\n");rn bzero(buffer2,sizeof(buffer2));rn n=read(pthread->clientsocket,buffer2,sizeof(buffer2));rn printf("read=%d\n",n);rn printf("%s\n",buffer2);rn if(strcmp(buffer2,"quit")==0)rn break;rn rn fwrite(buffer2,n,1,fp);rn rn rn printf("recv over\n");rn fclose(fp);rnrnrn 客服端:rn fd=open(mp.filename,O_RDWR);rn if(fd==-1)rn rn perror("open file error!");rn exit(1);rn rn lseek(fd,0,SEEK_SET);rn bzero(buffer,sizeof(buffer));rn while((n=read(fd,buffer,sizeof(buffer)))>0)rn rn m=write(socket2,buffer,strlen(buffer));rn printf("write=%d\n",m);rn printf("%s\n",buffer);rn sleep(1);rn bzero(buffer,sizeof(buffer));rn rn close(fd);rn bzero(buffer,sizeof(buffer));rn strcpy(buffer,"quit");rn sleep(1);rn write(socket2,buffer,strlen(buffer));rn printf("%s\n",buffer);rn printf("update file over!\n");rnrnrn 客服端终端<em>信息</em>如下:rn Update Files:b.c //输入文件,打印如下rn write=11rn 123456rn 789rnrn quitrn update file over!rnrnrn 服务端终端<em>信息</em>如下:rn abcrn read=4rn quitrn recv over //每次客服端输入文件名,服务端就只打印这四句。rnrnrn 求高手指正一下!
idUdpServer 接收不到数据
在ActiveFormX中使用idUdpServerrn//初始化rnwith idUDPServer1.Bindings.Add dornbeginrn IP:='';rn Port:=6013;rnend;rnidUDPServer1.active:=True;rnrn//idUDPServer1UPPRead 事件处理rnshowmessage('hello');rnrn该程序在ie中使用程序打开后rn用天网防火墙观察看到 ie有在UDP 6013端口监听rn当服务端发来<em>数据</em>时候rn天网防火墙发现ie有在UDP 6013端口监听目的指向了rn服务端ip端口也正确 rn但程序没有按设计的那样出提示rn点了一下IE的刷新 发现程序出 'hello' 提示了rn好像ie 不会把<em>数据</em>提交给程序 只在要刷新时一下提交rn这怎么回事rn希望大家帮助
为什么接收不到数据
我写的上位机程序,用串口助手可以<em>接收</em>到它发来的<em>数据</em>,问什么它<em>接收</em><em>不到</em>串口助手发过来的<em>数据</em>,下面是它<em>接收</em><em>数据</em>的代码,大家帮我看看,谢谢!rnrnprocedure TForm1.Button7Click(Sender: TObject);rnrnvarrndata:string;rnBufferLength:word;rnBuffer:Pointer;rnbegin rnSetLength(data,BufferLength);rnmove(Buffer^,pchar(data)^,Bufferlength);rnMemo1.lines.Add(data);rnMemo1.Invalidate;rnrnend;
求教为何接收不到参数。。
else n $.ajax(n type: "POST",n url: "addXZYW.aspx/SetBaoCun",n //data: id: id, mc: mc, mc: mc,engname: engname,shuruma: shuruma,tym: tym, n data: "id:'" + id + "',mc:'" + mc + "',engname:'" + engname + "',shuruma:'" + shuruma + "',tym:'" + tym + "'",n contentType: "application/json; charset=utf-8",n dataType: "json",n async: false,n error: function (XMLHttpRequest, textStatus, errorThrown) ,n success: function (data) n );n ;n n 这样后台怎么收<em>不到</em><em>数据</em>呢?n 后台:n [System.Web.Services.WebMethod]n public void SetBaoCun(string id, string mc, string engname, string shuruma,string tym)n n //string id1 = id; string mc1 = mc; string engname1 = engname; string shuruma1 = shuruma; string tym1 = tym;n string sql = string.Format(@"insert into zsk_yaopin(id,name,engname,shuruma1,commonname) values(0,1,2,3,4)", id, mc, engname, shuruma, tym);n DbAccess.ExecuteNonQuery(DbAccess.m, CommandType.Text, sql); n nn
recvfrom接收不到数据
在一个<em>接收</em>子线程里面<em>接收</em>下位机上送的<em>数据</em>,如下: rn while (ConnectFlag)rnrn if (pDlg->RecvFlag)rn rn int err = recvfrom(pDlg->socketclient,recvbuf,1000,0,(SOCKADDR*)&addrsv,&lenp);rn rnrn流程:上位机先下发命令给下位机配置参数,下位机一旦收到相应的<em>信息</em>(不是前句话讲的参数命令)就开始上送<em>数据</em>。<em>问题</em>:如果下位机停止上送<em>数据</em>接近一分钟,再次上送<em>数据</em>,recvfrom却<em>接收</em><em>不到</em><em>数据</em>,从PC端的截包工具已经看到下位机上送了<em>数据</em>且<em>数据</em>格式内容正确,这个时候只有再下发一次命令后,下位机一旦收到相应<em>信息</em>,recvfrom又能收到<em>数据</em>,至少说明<em>接收</em>子线程没有退出。注明:下发命令其实主要就是sendto函数,“截包工具已经看到下位机上送了<em>数据</em>”说明配置参数命令其实已经在下位机了,不明白为什么要再次下发命令一下又才能recvform。rn我把 recvfrom改成非<em>阻塞</em>模式,也是同样的现象。
GCDAsyncSocket 接收不到数据
GCDAsyncSocket <em>接收</em><em>不到</em><em>数据</em>
后端接收不到数据
@RestController @RequestMapping("/itemsearch") public class ItemSearchController { @Reference private ItemSearchService itemSearchService; @RequestMapping("/search") public Map&lt;St...
电脑接收不到数据?
电脑连上网络后,<em>接收</em><em>不到</em><em>数据</em>,查看IP都是正确的,但是PING不通网关,本机能PING通,是怎么回事?
串口接收不到数据
各位大侠:rn 最近在写一个吊称<em>数据</em>获取程序,通过RS232获取<em>数据</em>,但是吊称跟电脑连接后,C#程序获取<em>不到</em>任何<em>数据</em>,serialPort1_DataReceived事件不能触发,不知道是什么原因?请问怎么样才能<em>接收</em>到串口的<em>数据</em>?我将自个电脑的串口2,3脚短接就能接受到自己发出的<em>数据</em>!rn
openwithparm接收不到数据
如题,我在w_1中添加了一个按钮,按钮的clicked事件中代码如下:rnlong ll_rowrnstring ls_nbrrnint li_countrnll_row = dw_1.rowcount()rnif ll_row > 0 thenrn ls_nbr = dw_1.object.do_mstr_do_nbr[dw_1.getrow()]rn select count(*) into :li_count from tr_histrn WHERE tr_nbr=:ls_nbr;rn if li_count>0 thenrn messagebox('提示','仓库已经输入<em>数据</em>,你无法修改该单据!')rn return -1rn elsern openwithparm(w_2, ls_nbr)rn end if;rnend if rn在w_2的open中代码如下:rnstring ls_message,ls_deptrnrnrnls_message = message.stringparmrnis_nbr= ls_messagernrndw_1.retrieve(is_nbr)rn用messagebox来条显示在w_1中的代码有实现,且debug运行有看到message.stringparm有值,但是打开了w_2后,就为空,rn请高手不吝赐教
问题:gprs_dtu接收不到数据?
BOOL DSGetNextData(DtuDataStruct* pDataStruct,u16t waitseconds)rn功能:读取下一条Dtu送上来的<em>信息</em>rn参数:pDataStruct: 存放Dtu所送上来的<em>信息</em>和<em>数据</em>的结构,读函数执行成功后,返回的<em>数据</em>存放到该参数指向的结构中rnwaitseconds:本函数读到<em>数据</em>后立即返回;如果没有<em>数据</em>到达,则等待最长waitseconds(时间单位:秒)的时间,直到有<em>数据</em>到达,取值范围从0~65535,如果取值为0表明本函数将立即返回。另外,当在另一个线程中执行成功了DSStopService()后,本函数将立即返回。rn返回:如果返回为非零值,表明收到了一条Dtu<em>信息</em>。如果返回为0,则表明没有收到<em>数据</em>。rnrnrn上面是gprs_dtu<em>数据</em><em>接收</em>函数,我设定每5秒执行一次,为什么每次都读<em>不到</em><em>数据</em>呢?有谁做过这方面,给点意见啊。rnrn听人说,可能是啥维系连接,注册包之类的<em>问题</em> ,不懂啊
为何接收不到WM_TIMER消息???
用DirectDraw编程是,我以全屏独占的方式创建了一个窗口,但<em>为何</em>它<em>接收</em><em>不到</em>WM_TIMER消息呢?其他消息好象都可以<em>接收</em>(鼠标消息).
服务器程序为何接收不到空格
以下是程序rn[code=C/C++]rnwhile(1)rn rn SOCKADDR_IN addrClient;rn rn int len=sizeof(SOCKADDR);rn SOCKET recv_socket=((RECVPARAM*)lpParameter)->sock_refer;rn HWND hwnd=((RECVPARAM*)lpParameter)->hwnd;rn //delete lpParameter;rn rn SOCKET sockConn=accept(recv_socket,(SOCKADDR*)&addrClient,&len);//等待客户请求到来;当请求到来后,接受连接请求,返回一个新的对应于此次连接的套接字(accept)rn if(sockConn==SOCKET_ERROR)rn rn AfxMessageBox("<em>数据</em><em>接收</em>失败!");rn //error=WSAGetLastError();rn closesocket(sockConn);rn return 0;rn rn char recvBuf[1000];rn memset(recvBuf,'\0',1000);rn recv(sockConn,recvBuf,1000,0);rn if(recvBuf[0]=='H'&&recvBuf[1]=='E'&&recvBuf[2]=='L'&&recvBuf[3]=='P')rn rn char recvdataram[1000];rn int i;rn mode=1;rn ::PostMessage(hwnd,WM_RECVDATA,0,0);rn remoteram[0]=0;rn while(!remoteram[0])rn Sleep(100);rn send(sockConn,remoteram,100,0);//用返回的套接字和客户端进行通讯rn memset(recvdataram,'\0',1000);rn database[0]='\0';rn for(i=0;i'9')rn database[i]=database[i]-0x37;rn elsern database[i]=database[i]-0x30;rn if(database[i+1]>'9')rn database[i+1]=database[i+1]-0x37;rn elsern database[i+1]=database[i+1]-0x30;rn database[(i/2)]=database[i]*16+database[i+1];rn rn closesocket(sockConn);rn mode=3;rn ::PostMessage(hwnd,WM_RECVDATA,0,0);rn mode=2;rn ::PostMessage(hwnd,WM_RECVDATA,0,0);rn rn elsern rnrn DWORD dwAddress=ntohl(addrClient.sin_addr.S_un.S_addr);rn char OK[]="OK";rn int Length_ok=strlen(OK);rn int send_ok=send(sockConn,OK,Length_ok,0);//用返回的套接字和客户端进行通讯rn if(send_ok==SOCKET_ERROR)rn AfxMessageBox("发送过程中发生一个错误!",NULL,MB_OK);rn// closesocket(sockConn);rn mode=0;rn ::PostMessage(hwnd,WM_RECVDATA,(WPARAM)dwAddress,(LPARAM)recvBuf);rn rn rnrnrn[/code]rn当ACCEPT<em>接收</em>客户端其它字符串<em>数据</em>的话没有<em>问题</em>,但一旦客户端发送空格(ASCII 为20)的话就无限<em>阻塞</em><em>接收</em><em>不到</em>了
完成端口接收不到数据
#include "Server.h"rn#include rn#include rn#include rnrnstatic DWORD WINAPI subThread( LPVOID lpParameter )rnrn DWORD bytesCnt;rn HANDLE cphdl = ( HANDLE )lpParameter;rn SOCKET sock;rn LPOVERLAPPED pOverLapped;rn char *buf;rnrn while( 1 ) rn GetQueuedCompletionStatus( cphdl, &bytesCnt, ( PULONG_PTR )&buf, rn ( LPOVERLAPPED * )&pOverLapped, INFINITE );rnrn std::cout << bytesCnt << std::endl;rn rnrn return 0;rnrnrnbool Server::create()rnrn WSADATA wsaData;rn WSAStartup( MAKEWORD( 2, 2 ), &wsaData );rnrn // 1. create a completion portrn HANDLE cpHdl = CreateIoCompletionPort( INVALID_HANDLE_VALUE, 0, 0, 1 );rn // 2. Create Socketrn SOCKET sock = createSock();rn // 3. create threadrn DWORD subThrdId;rn HANDLE thrdHdl = CreateThread( 0, 0, subThread, ( LPDWORD )cpHdl, 0, &subThrdId );rn CloseHandle( thrdHdl );rn // 4. listenrn startListen( sock, cpHdl );rnrn return true;rnrnrnSOCKET Server::createSock()rnrn SOCKET sock;rn sockaddr_in saServer;rn sock = WSASocket( AF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED );rn saServer.sin_family = AF_INET;rn saServer.sin_addr.s_addr = inet_addr( "127.0.0.1" );rn saServer.sin_port = htons( 5150 );rn bind( sock, ( SOCKADDR * )&saServer, sizeof( saServer ) );rn listen( sock, 1 );rn return sock;rnrnrnvoid Server::startListen( SOCKET sock, HANDLE cpHdl )rnrn SOCKET acceptSock;rn char *buf = ( char * )GlobalAlloc( 0, 256 );rn WSABUF wsaBuf = 256, buf ;rn DWORD bytesCnt;rn DWORD flag = 1;rn WSAOVERLAPPED overLapped;rn bool ret = false;rnrn while( 1 ) rn acceptSock = WSAAccept( sock, NULL, NULL, 0, 0 );rn std::cout << "accept" << std::endl;rn CreateIoCompletionPort( ( HANDLE )acceptSock, cpHdl, ( DWORD )buf, 1 );rn ZeroMemory( &overLapped, sizeof( overLapped ) );rn char *msg = "main thread";rn WSARecv( acceptSock, &wsaBuf, 1, &bytesCnt, &flag, &overLapped, 0 );rn send( acceptSock, msg, strlen( msg ), 0 );rn int err = WSAGetLastError();rn rnrnrn不明白<em>问题</em>出在哪里,一些关键步骤都有检查过,没有什么错误。还请高手指教rn
recv接收不到数据!!
while(1)rn rn byte_count = recv(sock, buf, sizeof(buf), 0);rn if(byte_count>0)rn rn return 1;rn rn elsern rn continue;rn rn rn 这样都<em>接收</em><em>不到</em><em>数据</em>。郁闷中................
UDP接收不到数据
服务端代码:rn private void lxcMain_Load(object sender, EventArgs e)rn rn int recv;rn byte[] revData = new byte[1024];rn byte[] sendData = new byte[1024];rn IPAddress address = IPAddress.Parse("192.168.31.80");rn IPEndPoint ip = new IPEndPoint(address, 6667);rn Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);rn newsock.Bind(ip);rn IPEndPoint sender1 = new IPEndPoint(address, 0);rn EndPoint Remote = (EndPoint)(sender1);rn recv = newsock.ReceiveFrom(revData, ref Remote);rn rn客户端代码放在板子上通过以太网连接。rn代码在项目中ReceiveFrom<em>接收</em><em>不到</em><em>数据</em>。新建一个测试项目复制同样代码就可以<em>接收</em><em>数据</em>了。 请问,可能会有什么原因造成?
阻塞接收问题
我用的是线程<em>阻塞</em><em>接收</em>,如果线路断了,我的线程<em>接收</em>(也就是在recv()函数处)就会<em>阻塞</em>了,但我如何知道线程已被<em>阻塞</em>,还有如何从线程<em>阻塞</em>中退出。rnrnrn急,急,急呀!!!!
udp接收组播数据丢帧问题
现在又两个线程rnrn一个线程做<em>接收</em>视频流,另一个解码显示。rnrn现在<em>接收</em>线程在接受<em>组播</em><em>数据</em>的时候会丢帧,视频每帧不超过4096,通常在1k左右,rn我接受端的代码如下 各位高手帮我看看 急死我了rnint iRet = select(0,&fdRead,NULL,NULL,&timeout);rnrnif(iRet < 1)rnreturn;rn rnm_nDataRecv = recv(m_socketupd, (char *)pBuffer, sizeof(pBuffer), 0); rnrn现在我把pbuffer的<em>数据</em>保存成文件,发现会丢帧,不知道为什么,刚开还正常 后来就越来越严重了
求助!接收VLC播放器组播数据问题
[size=24px]Server端用VLC<em>组播</em>发送视频,打算Client<em>接收</em>存储视频流,现在用Socket套接字,显示加入<em>组播</em>都有<em>问题</em>,请问,可不可以自己写Socket<em>接收</em>VLC 发送的<em>组播</em>视频呢?请您指点一下[/size]
我没辙了,组播接收问题
下面函数创建套接字,<em>组播</em>发送,广播发送,广播<em>接收</em>都没<em>问题</em>,rn但是<em>组播</em><em>接收</em><em>不到</em><em>数据</em>rnudp_socket(WORD port)rnrn SOCKET s;rn struct ucb_t* ucb;rn SOCKADDR_IN localAddr;rn int cflag = 1;rn struct ip_mreq mreq; rnrn InitSocketAPI();rnrn s = socket(AF_INET,SOCK_DGRAM,0);rn if (s == INVALID_SOCKET)rn return 0;rnrn //支持广播rn if( setsockopt(s, SOL_SOCKET,SO_BROADCAST,(char*)&cflag,sizeof(cflag)) == -1)rn rn closesocket(s);rn return 0;rn rnrn //支持重复打开rn if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&cflag,sizeof(cflag)) == -1)rn rn closesocket(s);rn return 0;rn rnrnrn localAddr.sin_family = AF_INET;rn localAddr.sin_port = htons(port);rn localAddr.sin_addr.s_addr = INADDR_ANY;rn if (bind(s, (SOCKADDR *)&localAddr, sizeof(localAddr))==SOCKET_ERROR)rn rn closesocket(s);rn return 0;rn rnrn //支持<em>组播</em>rn memset(&mreq, 0, sizeof(mreq));rn mreq.imr_interface.S_un.S_addr = htonl(INADDR_ANY);rn mreq.imr_multiaddr.S_un.S_addr = inet_addr("235.255.255.250");rn if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq)) == -1)rn rn closesocket(s);rn return 0;rn rnrn
c++builder6下udp组播接收问题
以前用控件TNMUDP来做过udp的收发,现在想做<em>接收</em><em>组播</em>功能,不知怎么用。求教了!
百度推送-接收不到问题
本人使用小米2手机测试发现百度推送会有<em>接收</em><em>不到</em>的情况,解决方案   1、删除sd卡根目录的baidu文件夹(本人删除后推送能够<em>接收</em>到) 2、http://blog.csdn.net/vinrex/article/details/40008149(未测试过,感觉靠谱) ...
怎么接收组播
delphi怎么<em>接收</em><em>组播</em>的<em>数据</em>?
组播发送和接收
MFC下写的<em>组播</em>发送并显示,基于windows平台
linux组播接收和发送
客户端<em>接收</em>到后如何发送一个应答给服务器?
组播发送接收
<em>组播</em>发送<em>接收</em>,C++做的简单例子实现<em>组播</em>的发送和<em>接收</em>,适合初学者学习
QUdpSocket多网卡组播接收
我的开发环境是Qt4.8,使用Qt来写<em>组播</em>的时候遇到了多网卡的<em>问题</em>。rn<em>组播</em>的代码在单网卡的环境下可以正常工作,但是一旦计算机里存在2个或者2个以上的网卡,QUdpSocket就无法正常<em>接收</em><em>组播</em>包。rn我尝试将每个网卡的每个IPv4都绑定到一个QUdpSocket,通过轮询的方式来解决,但是仍然不工作。使用Wireshark抓包,可以正常发送,对端也会有返回,但是Qt没有反应。rn这个解决方法使用socket接口可以正常解决。
组播发送和接收
我正在写一个<em>组播</em>程序,想使用CSocket做rn可是找资料基本上没有找到用CSocket做的<em>组播</em>发送和<em>接收</em>程序rnrn请问用CSocket可以做<em>组播</em>程序吗?rn如果不可以,用什么最简单?rn如果可以,请列出简单代码,并说明应该注意什么<em>问题</em>,谢谢
udp组播发送接收
udp<em>组播</em>发送<em>接收</em>的发送端, <em>接收</em>端,测试程序
关于SOCKET接收不到数据
发送端:rn结构体rntypedef struct head_packetrnrn char type[20]; //类型rn int length; //长度rn char aque[20]; //序列号 rn ST_HEAD_PACKET;rn发送<em>数据</em>:rn strncpy(head_package->type , "log" , sizeof("log"));rn head_package->length = strlen(head_package->type);rn strncpy(head_package->aque , "log" , sizeof("log"));rnrn writen(sd , head_package, sizeof(struct head_packet));rn函数:rnssize_t writen(int fd, const void *ptr, size_t n)rnrn size_t nleft;rn ssize_t nwritten;rnrn nleft = n;rn while (nleft > 0) rn if ((nwritten = write(fd, ptr, nleft)) < 0) rn if (nleft == n)rn return(-1); /* error, return -1 */rn elsern break; /* error, return amount written so far */rn else if (nwritten == 0) rn break;rn rn nleft -= nwritten;rn ptr += nwritten;rn rn return(n - nleft); /* return >= 0 */rnrn<em>接收</em>端:rn head_package = (ST_HEAD_PACKET *)malloc(sizeof(struct head_packet));rn memset(head_package , 0 , sizeof(struct head_packet));rn readn(sd , head_package , sizeof(head_package));rn printf("%s\n" , head_package->type);rn printf("%s\n" , head_package->aque);rn<em>问题</em>:rn<em>接收</em>端只能收到head_package->type 不能<em>接收</em>到head_package->aque
raw socket接收不到数据
初学网络编程,照网上的例子写了个sniffer程序,可是执行到recv的时候,就没有返回了,估计是超时。请高人指点:rnrn[code=C/C++]rn#include "StdAfx.h"rn#include "Sniffer.h"rnrn#define SIO_RCVALL _WSAIOW(IOC_VENDOR,1)rn#define BUFFER_SIZE 65535rnchar RecvBuf[BUFFER_SIZE];rnrnUINT SniffThreadFun(LPVOID pParam);rnvoid SignalHandler(int sig);rnrnSniffer::Sniffer(void)rn : stopSniff(true)rnrnrnrnSniffer::~Sniffer(void)rnrnrnrnbool Sniffer::InitSocket(void)rnrn int err;rn int sockOpt = 1;rn char localName[100];rn struct hostent *hostPtr;rn SOCKADDR_IN sockAddr;rnrn WORD versionRequired = MAKEWORD(1,1);rn err = WSAStartup(versionRequired, &wsaData);rn if(err == SOCKET_ERROR)rn return false;rn sockRaw = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);rn if (sockRaw == INVALID_SOCKET)rn return false;rn err = setsockopt(sockRaw, IPPROTO_IP, IP_HDRINCL, rn (char*)&sockOpt, sizeof(sockOpt));rnrn if (err == SOCKET_ERROR)rn return false;rn err = gethostname(localName, sizeof(localName)-1);rn if (err == SOCKET_ERROR)rn return false;rn hostPtr = gethostbyname(localName);rn if (hostPtr == NULL)rn return false;rn sockAddr.sin_addr = *(in_addr *)hostPtr->h_addr_list[0];rn sockAddr.sin_family = AF_INET;rn sockAddr.sin_port = htons(57274);rn err = bind(sockRaw, (PSOCKADDR)&sockAddr, sizeof(sockAddr));rn if (err == SOCKET_ERROR)rn return false;rn return true;rnrnrnbool Sniffer::StartSniff(void)rnrn stopSniff = false;rn int err;rn unsigned long arg = 1;rnrn err = ioctlsocket(sockRaw, SIO_RCVALL, &arg);rn if (err == SOCKET_ERROR)rn int errCode = WSAGetLastError();rn return false;rnrn AfxBeginThread(rn (AFX_THREADPROC)SniffThreadFun, rn (LPVOID)this, rn THREAD_PRIORITY_NORMAL, rn 0, 0, NULL);rnrn return true;rnrnrnbool Sniffer::StopSniff(void)rnrn stopSniff = true;rn Sleep(2000);rn int err;rn DWORD arg = 0;rn err = ioctlsocket(sockRaw, SIO_RCVALL, &arg);rn if (err = SOCKET_ERROR)rn return false;rnrn return true;rnrnrnvoid Sniffer::DisposeSocket(void)rnrn WSACleanup();rn closesocket(sockRaw);rnrnrnUINT SniffThreadFun(LPVOID pParam)rnrn Sniffer *snifferPtr = (Sniffer *)pParam;rnrn while(!snifferPtr->stopSniff)rn rn //[color=#FF0000]执行recv的时候没有返回[/color]rn if (recv(snifferPtr->sockRaw, RecvBuf, BUFFER_SIZE, 0))rn rn snifferPtr->recvCallback(snifferPtr->pObserver, RecvBuf);rn rn rnrn return 0;rnrn[/code]
前台为什么接收不到数据
今天花了一上午,后台是证正常的,struts.xml是正常的 。但是就是说找<em>不到</em>这个方法。 最后发现是因为方法应该是public 但是手误成了private
通信上了接收不到数据
实现个远程注销功能 初学IOCP想试试 通信成功了 但<em>接收</em><em>数据</em>好象收<em>不到</em> 点完注销按钮没反映,找不出什么毛病rn烦劳高手慧眼识错 感激不尽rnrn服务端IOCP模型rn#include rn#include rn#define BUFFER_SIZE 1024rnrntypedef struct _PER_HANDLE_DATArnrn SOCKET s;rn sockaddr_in addr;rnPER_HANDLE_DATA,*PPER_HANDLE_DATA;rnrntypedef struct _PER_IO_DATArnrn OVERLAPPED ol;rn char buf[BUFFER_SIZE];rn int nOperationType;rn#define OP_READ 1rn#define OP_WRITE 2rn#define OP_ACCEPT 3rnPER_IO_DATA,*PPER_IO_DATA;rnrnchar *ID="PowerOff";rnDWORD WINAPI ServerTheard(LPVOID lpParam);rnrnvoid main()rnrn WORD wVersionRequested;rn WSADATA wsaData;rn int err;rn rn wVersionRequested = MAKEWORD( 2, 2 );rn rn err = WSAStartup( wVersionRequested, &wsaData );rn if ( err != 0 ) rn return;rn rn rn rn if ( LOBYTE( wsaData.wVersion ) != 2 ||rn HIBYTE( wsaData.wVersion ) != 2 ) rn WSACleanup( );rn return; rn rn HANDLE hCompletion=CreateIoCompletionPort(INVALID_HANDLE_VALUE,0,0,0);rn CreateThread(NULL,0,ServerTheard,(LPVOID)hCompletion,0,0);rn rnrn SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);rn SOCKADDR_IN addrSrv;rn addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY);rn addrSrv.sin_family=AF_INET;rn addrSrv.sin_port=htons(12345);rn rn bind(sockSrv,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));rn rn listen(sockSrv,5);rn rn SOCKADDR_IN addrClient;rn int len=sizeof(SOCKADDR);rnrn while(1)rn rn rn SOCKET sockConn=accept(sockSrv,(SOCKADDR*)&addrClient,&len);rn PPER_HANDLE_DATA pHandle=(PPER_HANDLE_DATA)GlobalAlloc(GPTR,sizeof(PPER_HANDLE_DATA));rn pHandle->s=sockConn;rn memcpy(&pHandle->addr,&addrClient,len);rn CreateIoCompletionPort((HANDLE)pHandle->s,hCompletion,(DWORD)pHandle,0);rn rn PPER_IO_DATA pIo=(PPER_IO_DATA)GlobalAlloc(GPTR,sizeof(PPER_IO_DATA));rn pIo->nOperationType=OP_READ;rn rn WSABUF buf;rn buf.buf=pIo->buf;rn buf.len=BUFFER_SIZE;rn DWORD dwRecv;rn DWORD dwFlags=0;rn WSARecv(pHandle->s,&buf,1,&dwRecv,&dwFlags,&pIo->ol,NULL);rn rn rnrnrnrnrnDWORD WINAPI ServerTheard(LPVOID lpParam)rnrn HANDLE hCompletion=(HANDLE)lpParam;rn DWORD dwTrans;rn PPER_HANDLE_DATA pHandle;rn PPER_IO_DATA pIo;rnrn while (TRUE)rn rn BOOL bOK=GetQueuedCompletionStatus(hCompletion,&dwTransrn ,(LPDWORD)&pHandle,(LPOVERLAPPED*)&pIo,WSA_INFINITE);rn if (!bOK)rn rn closesocket(pHandle->s);rn GlobalFree(pHandle);rn GlobalFree(pIo);rn continue;rn rn if (dwTrans==0&&(pIo->nOperationType==OP_READ||pIo->nOperationType==OP_WRITE))rn rn closesocket(pHandle->s);rn GlobalFree(pHandle);rn GlobalFree(pIo);rn continue;rn rn switch(pIo->nOperationType)rn rn case OP_READ:rn rn rn if (ID==pIo->buf)rn rn ExitWindowsEx(EWX_LOGOFF,0); //就是实现个远程注销功能rn rn WSABUF buf;rn buf.buf=pIo->buf;rn buf.len=BUFFER_SIZE;rn DWORD dwRecv;rn DWORD dwFlags=0;rn WSARecv(pHandle->s,&buf,1,&dwRecv,&dwFlags,&pIo->ol,NULL);rn rn break;rn case OP_WRITE:rn break;rn case OP_ACCEPT:rn break;rn rn rn rn return 0;rnrnrn客户端:rnrnchar *ID="PowerOff";rnvoid CPowerOffDlg::OnBtnPoweroff() rnrn // TODO: Add your control notification handler code herern send(m_sock,ID,strlen(ID)+1,0);rn rn
wince 串口接收不到数据
各位麻烦给指点一下,我的串口<em>接收</em>长时间<em>接收</em>之后就<em>接收</em><em>不到</em><em>数据</em>了,不知道怎么解决,还望各位帮忙看看!下面是我的<em>接收</em>线程,过几个小时后就<em>接收</em><em>不到</em><em>数据</em>了,我的线程<em>接收</em>来自模块的串口<em>数据</em>,模块不停的每隔400毫秒发一次<em>数据</em>rnDWORD CRsCom::CommRecvTread(LPVOID lparam)rnrn DWORD dwLength;rn char *recvBuf = new char[512];rn CRsCom *pDlg = (CRsCom*)lparam;rn COMSTAT ComStat;rn DWORD dwErrorFlags;rn PurgeComm(pDlg->m_hComm,PURGE_RXCLEAR|PURGE_TXCLEAR); //清空串口的<em>接收</em>缓 冲区,必要性不大rn ClearCommError(pDlg->m_hComm,&dwErrorFlags,&ComStat); //清除串口状态标rn while(TRUE)rn rn PurgeComm(pDlg->m_hComm,PURGE_RXCLEAR|PURGE_TXCLEAR); //清空串口的<em>接收</em>缓 冲区,必要性不大,但有rn //ClearCommError(pDlg->m_hComm,&dwErrorFlags,&ComStat); //清除串口状态标rn if (WaitForSingleObject(pDlg->m_ExitThreadEvent, 0) == WAIT_OBJECT_0 )rn break; rn if (pDlg->m_hComm != INVALID_HANDLE_VALUE )rn rn ClearCommError(pDlg->m_hComm,&dwErrorFlags,&ComStat);rn BOOL fReadState = ReadFile(pDlg->m_hComm, recvBuf, 512, &dwLength, NULL);rn if(!fReadState)rn rn //MessageBox(_T("无法从串口读取<em>数据</em>!"));rn rn elsern rn if(dwLength!=0)rn rn OnCommRecv(pDlg, recvBuf, dwLength); rn rn rn rn rn delete[] recvBuf;rn return 0;rn
udp通讯接收不到数据
http://www.cnblogs.com/keyvip/archive/2010/11/16/1878713.html用的这个大神的代码rn我用的delphi xe7rn<em>接收</em>端<em>接收</em><em>不到</em><em>数据</em>,用网上其它的网络调试工具可以<em>接收</em>到<em>数据</em>rnprocedure TForm1.idpsrvr1UDPRead(AThread: TIdUDPListenerThread;rn const AData: TStream; ABinding: TIdSocketHandle);rn var Comm:TCommBlock;rnbeginrn AData.ReadBuffer(Comm,SizeOf(Comm));rn mmo1.Lines.Add('Comm');rnend;rn是不是这个函数有<em>问题</em>?初学,请大神指点。谢谢
阻塞socket问题为何有些socket接收不到数据
一台服务器要从两台客户计算机通过HUB相连,服务器要从客户端<em>接收</em>7类<em>数据</em>,使用<em>组播</em>方式<em>接收</em>,每一类<em>数据</em>都要使用单独的socket,而且每一类<em>数据</em>都是由客户端以40ms的频率周期性发送。服务器端的<em>接收</em>程序是这样设计的:socket是无<em>阻塞</em>式的,<em>数据</em><em>接收</em>程序是一个单独的线程,采用循环结构,使用select()函数对这7个socket进行<em>阻塞</em>式查询。出现的<em>问题</em>是:不是所有的socket能检测到<em>数据</em>的到来,比如总是检测到4和5有<em>数据</em>到来,而从其他socket则不会检测到<em>数据</em>到来;或者当屏先不向socket4、5发送<em>数据</em>,其他Socket会检测到有<em>数据</em>到来,此时如启动向socket4、5发送<em>数据</em>时,运行一段很短的时间后,会导致其他socket检测<em>不到</em><em>数据</em>到来。这是什么原因哪?请高手不吝赐教!rn 一种推测是:<em>数据</em>量太大,导致网卡中的<em>数据</em>缓存溢出而丢失楨。rn rn
axios数据php接收不到
axios发送异步 PHP<em>接收</em><em>不到</em>解决方案 发送异步<em>数据</em>格式不是Form Data Content-Type: application/x-www-form-urlencoded 解决办法: 引入qs库 https://github.com/ljharb/qs const qs = require('qs'); axios.post('/foo', qs.string...
SOCKET连接接收不到数据
现在手头有个项目要建立PHP(client)和JAVA(server)的SOCKET连接,传递<em>数据</em>:rnrn现在SOCKET连接建立是成功的,而且PHP发过来的测试<em>数据</em>,在SERVER端也是收的到的rnrn<em>问题</em>是SERVER发出的<em>数据</em>,在PHP<em>接收</em><em>不到</em>。请问各位有何看法啊?rnrn背景资料:rn1.SERVER端发送<em>数据</em>应该是成功的(不确定),因为并没有任何报错rn2.PHP老是出现这样的警告:rnWarning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in G:\AppServ\www\sock\index1.php on line 4rnrn第4行:if (! ($fd = fsockopen("192.168.0.103",8888,&$error_number,&$error_des,60)))rnrn3.PHP接受<em>数据</em>用的rnecho fgets($fd,100000);rnrn4. JAVA端发送<em>数据</em>是:rnOutputStream out = clientSocket.getOutputStream();rnPrintWriter out1 = new PrintWriter(out,true); rnout1.println("我是007");
xmlHttp接收不到数据,怎么回事?
function getLabelsGet() rn  xmlHttp=GetXmlHttpObject(); rn  if (xmlHttp==null) rn    alert('您的浏览器不支持AJAX!'); rn    return; rn   rn  var url="getstock.php?token="+token+"&key="+key+"&p1="+p1+"&p2="+p2; rnrn  xmlHttp.open("GET",url,true); rn  xmlHttp.onreadystatechange=getOkGet;//发送事件后,收到<em>信息</em>了调用函数 rn  xmlHttp.send(); rnrnfunction getStock() rn rn  xmlHttp=GetXmlHttpObject(); rn  if (xmlHttp==null) rn    alert('您的浏览器不支持AJAX!'); rn    return; rn   rn  var url="http://hq.sinajs.cn/list=sh601168"; rnrn  xmlHttp.open("GET",url,true); rn  xmlHttp.onreadystatechange=getStockOK;//发送事件后,收到<em>信息</em>了调用函数 rn  xmlHttp.send(); rnrnrnfunction getStockOK() rn rn  if(xmlHttp.readyState==1||xmlHttp.readyState==2||xmlHttp.readyState==3) rn    // 本地提示:加载中 rn   rn if(xmlHttp.readyState==4)rnrn rn var data = xmlHttp.responseText;rn alert(data);rn rn rn  rn rngetStock();rnrn我打算取出字符串自己进行拆解,可是取<em>不到</em><em>数据</em>,该如何得到返回的字符串?并进行拆解呢?
求助:为什么接收不到数据
我是新手,前几天跟着网上学写了一个VC++的ping程序,采用原始套接字收发<em>数据</em>,但我运行的时候,<em>数据</em>可以发送,但是<em>接收</em>的时候只有将本机设为目标地址才可以,当我ping了一下其他网站,程序就死了,我调试了几天了,也找不出哪里有<em>问题</em>,我快崩溃了,求助各位大虾指点指点,(我ICMP报文头和<em>数据</em>部分用校验和函数校验过没有<em>问题</em>)
UDP为什么接收不到数据?
我做了一个UDP程序,可是不能互传<em>数据</em>,请大家帮忙!rn服务器端:rn Public Sub exam2()rn ' This constructor arbitrarily assigns the local port number.rn Dim udpClient As New UdpClientrn Tryrn udpClient.Connect(IPAddress.Parse("192.168.30.51"), 13579)rn Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Parse("192.168.30.51"), 13579)rn Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)rn Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)rn MessageBox.Show(("This is the message you received " + _rn returnData.ToString()))rn MessageBox.Show(("This message was sent from " + _rn RemoteIpEndPoint.Address.ToString() + _rn " on their port number " + _rn RemoteIpEndPoint.Port.ToString()))rn udpClient.Close()rn Catch e As Exceptionrn MessageBox.Show(e.ToString())rn End Tryrn End Subrn客户端:rn Dim udpClient As New UdpClientrn Tryrn udpClient.Connect(IPAddress.Parse("192.168.30.51"), 13579)rn Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there?")rn udpClient.Send(sendBytes, sendBytes.Length)rn udpClient.Close()rn Catch e As Exceptionrn MessageBox.Show(e.ToString())rn End Tryrn请问错在哪了?
用TWinSocketStream接收不到数据
ClientSocket用<em>阻塞</em>方式,thread中创建,rnTClientSocket *pClientSocket=new TClientSocket(NULL);rn pClientSocket->Address="127.0.0.1";rn pClientSocket->Port=7500;rn pClientSocket->ClientType=ctBlocking;rn rn pClientSocket->Active=true;rnrnvoid __fastcall socketthread::Execute()rnrn //---- Place thread code here ----rn TClientSocket *pClientSocket=new TClientSocket(NULL);rn pClientSocket->Address="127.0.0.1";rn pClientSocket->Port=7500;rn pClientSocket->ClientType=ctBlocking;rn pClientSocket->Socket->ClientType=ctBlocking;rn pClientSocket->Active=true;rnrnwhile(!Terminated)rnrn if(pClientSocket->Active)rn rn const int nBufferCount=2000;rn char cBuffer[nBufferCount];rn TWinSocketStream *pStream;rnrn tryrn rn pStream = new TWinSocketStream(pClientSocket->Socket, 4000);rnrn tryrn rnrn memset(cBuffer,0,nBufferCount);rn pStream->WaitForData(4000);rn //char quest[]="wait";rn //pStream->Write(quest.strlen(quest));rn int i=pStream->Read(cBuffer,strlen(cBuffer));rn Form1->Edit2->Text=AnsiString(cBuffer);rn rn rn catch (Exception &E)rn rn ::MessageBox(NULL,E.Message.c_str(),"eerr",MB_OK);rn rn rn __finallyrn rn delete pStream;rn rn rnrnrnrnrnServerSocket在ClientConnect事件中写rnvoid __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,rn TCustomWinSocket *Socket)rnrn Socket->SendText("ServerSocket1ClientConnectokok");rnrn但是接受<em>不到</em><em>数据</em>,不用thread,ClientSocket用非<em>阻塞</em>,在onread事件却可以独到,help me
C#串口通讯接收不到数据
rn我用C#写的串口通讯软件,串口通讯类用的是.Net的[color=#339966]SerialPort[/color]类。rn不知道为什么,同样的操作,[color=#FF00FF]有时候PDA发送的<em>数据</em>能够<em>接收</em>到,有时候<em>接收</em><em>不到</em>。[/color]rn而以前别人用Delphi写的串口通讯软件都能和PDA正常通讯。(和我现在做的这个功能一模一样,也是与PDA通讯)并且我们的串口参数:波特率等都设置的一样。
MFC 串口通信 接收不到数据
程序之前写好了,运行没<em>问题</em>。但后来我重装了系统,所以要重新装了环境。导致现在的程序出现了<em>问题</em>,只能发送<em>数据</em>了,不能<em>接收</em><em>数据</em>(我从网上也下载了好几个写的代码,发现是同样的<em>问题</em>)。rn程序可以运行,但一旦<em>接收</em><em>数据</em>,调试栏就会有这样的异常[img=https://img-bbs.csdn.net/upload/201511/04/1446604050_979741.png][/img]rnDemo.exe 中的0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0030eb7c 处的 COleDispatchException。rnDemo.exe 中的0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x00000000 处的 [rethrow]。rn之后我只运行。发现这样的提示rnDemo.exe 中的0x753db9bc 处最可能的异常: 0x000006BA: RPC 服务器不可用。rnDemo.exe 中的0x753db9bc 处最可能的异常: 0x000006BA: RPC 服务器不可用。rnDemo.exe 中的 0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0039cd20 处的 nNIVISA_PXI_PLUGIN_DM_15_0::nNIPXITOOLS000::tIniFileIOException。rnDemo.exe 中的 0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0039cd20 处的 nNIVISA_PXI_PLUGIN_DM_15_0::nNIPXITOOLS000::tIniFileIOException。rnDemo.exe 中的 0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0039cd20 处的 nNIVISA_PXI_PLUGIN_DM_15_0::nNIPXITOOLS000::tIniFileIOException。rnDemo.exe 中的 0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0039cd20 处的 nNIVISA_PXI_PLUGIN_DM_15_0::nNIPXITOOLS000::tIniFileIOException。rnDemo.exe 中的 0x753db9bc 处最可能的异常: Microsoft C++ 异常: 内存位置 0x0039e1fc 处的 _com_error。rn这些都与0x753db9bc有关。
串口通讯:接收不到完整的数据
用mscomm串口控件,rn设置<em>接收</em>20个字节时,触发事件,rnrn但有事件触发,但收到的<em>数据</em>不足20个字节。rnrn用BusHound监控查看,发现,是分二段<em>数据</em>还回。。rnrn请问下,这种情况要怎么处理?rnrn:会提示:rn
急!!!rs485 接收不到数据
RS485通信,带有RS232转485接口,用电脑的串口调试助手发送命令,在电脑上能看到有正确的<em>数据</em>返回,但是用FPGA发送同样的命令后,没有<em>数据</em>返回(FPGA的tx端有<em>数据</em>发送会亮绿灯,rx端有<em>数据</em>返回会亮红灯,发送端的<em>数据</em>接到电脑上看也是验证了正确的,但是就是没有<em>数据</em>返回,连红灯都不亮一下)求解啊!!用串口调试助手收发都没有<em>问题</em>,在FPGA的板上就不行了。。
C#串口通信 接收不到数据
[code=C#]rnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Linq;rnusing System.Text;rnusing System.Windows.Forms;rnusing System.IO.Ports;rnrnrnnamespace GPSPortrnrn public partial class Form1 : Formrn rn private SerialPort comm = new SerialPort();rn private StringBuilder builder = new StringBuilder();rn private long Receive_count = 0, Send_count = 0;rnrn public Form1()rn rn InitializeComponent();rn rnrn private void Form1_Load(object sender, EventArgs e)rn rn string[] ports = SerialPort.GetPortNames();rn Array.Sort(ports);rnrn PortName.Items.AddRange(ports);rn PortName.SelectedIndex = PortName.Items.Count > 0 ? 0 : -1;rn Baudrate.SelectedIndex = Baudrate.Items.IndexOf("9600");rnrn comm.NewLine = "\r\n";rn comm.RtsEnable = true;rnrn comm.DataReceived += comm_DataReceived;rn rn void comm_DataReceived(object sender,SerialDataReceivedEventArgs e)rn rn int n = comm.BytesToRead;rn byte[] buf=new byte[n];rn Receive_count += n;rn comm.Read(buf,0,n); rn string ReceiveText1;rn ReceiveText1 = builder.ToString();rn builder.Remove(0,builder.Length);rn label3.Text = "Get:" + Receive_count.ToString();rn this.Invoke((EventHandler)(delegatern rn builder.Append(Encoding.ASCII.GetString(buf));rn this.ReceiveText.AppendText(builder.ToString());rn ReceiveText1 = builder.ToString();rn string[] str =ReceiveText1.Split(',');rn foreach (string i in str) Arrtext.AppendText(i.ToString()+" ");rn ReceiveText.AppendText(ReceiveText1+"\n");rn ));rn rnrn private void button1_Click(object sender, EventArgs e)rn rn if (comm.IsOpen)rn rn comm.Close();rn rn elsern rn comm.PortName = PortName.Text;rn comm.BaudRate = int.Parse(Baudrate.Text);rn comm.ReadBufferSize = 4096;rn comm.WriteBufferSize = 4096;rn comm.DataBits = 8;rn comm.ReceivedBytesThreshold = 1024;rn tryrn rn comm.Open();rn rn catch (Exception ex)rn rn comm = new SerialPort();rn MessageBox.Show(ex.Message);rn rn rn button1.Text = comm.IsOpen ? "Close" : "Open";rn button2.Enabled = comm.IsOpen;rn rnrn private void button2_Click(object sender, EventArgs e)rn rn int n = 0;rn comm.Write(SendText.Text);rn n = SendText.Text.Length;rn Send_count+=n;rn label4.Text = "Set:" + Send_count.ToString();rn rn rnrnrn[/code]
我的Socket接收不到数据???
我写了一个多线程Socket服务端应用,Listen()后开线程处理,当一个客户端连接后,立即在线程里用Receive<em>接收</em>连<em>数据</em>,<em>接收</em>正常,rn 然后,这个连接不关闭,当Client端再发送<em>数据</em>的时候就收<em>不到</em>了,怎么办???
$.post回调函数接收不到数据
[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/2.gif][/img]是什么原因
RecvOneOrMore为什么接收不到数据
我测试socket的代码如下,发送一个长度为6字节,内容均为0的请求包,正常情况应该可以从服务器得到一个响应包,但是为什么这段代码<em>接收</em><em>不到</em><em>数据</em>,请高手赐教!谢谢rn[code=C/C++]void CTcpEngine::RunL()rn rn switch(iChannelState)rn rn case EChannelConnected:rn rn if (iStatus==KErrNone)rn rn // Connection was made successfullyrn iStatusText=_L("\nConnection established");rn NotifyProgress();rn rn rn TText8 pack[6] = 0, 0, 0, 0, 0, 0;rn iWriteDataBuffer.Append(pack, 6);rn rn iChannelState=EChannelSending;rn iSocket.Send(iWriteDataBuffer, 0, iStatus);rn SetActive();rn rn elsern rn iStatusText=_L("\nFailed to connect");rn NotifyProgress();rn rn rn break;rnrn case EChannelSending:rn rn // Receive data from the "server"rn iStatusText=_L("\nSent data");rn NotifyProgress();rnrn iSocket.RecvOneOrMore(iReadDataBuffer, 0, iStatus, iRecvLen);rn iChannelState=EChannelReceiving;rn SetActive();rn rn break;rnrn case EChannelReceiving:rn rn if (iStatus == KErrNone)rn rn // Data was received successfullyrn iStatusText=_L("\nReceived data");rn NotifyProgress();rn // Display received data in user interfacern //iStatusText=iReadDataBuffer;rn //NotifyProgress();rn rn elsern rn iStatusText=_L("\nError reading data");rn NotifyProgress();rn rnrn iStatusText=_L("\nClose the connection...");rn NotifyProgress();rnrn iSocket.Close();rn iStatusText=_L("\nEnd of test.");rn NotifyProgress();rn rn break;rn default:rn break;rn rn [/code]
ajax springmvc接收不到数据
后台 @RequestMapping(value = &quot;getAllChildByRId&quot;, method = RequestMethod.GET) public ModelAndView getAllChildByRId(String rId, Model model) { XLog.showLogInfo(&quot;rId = &quot; + rId); Model...
curl post接收不到数据
aa.php用curl函数向test.php POST<em>数据</em>rnrnaa.php内容:rn"aaa","pas"=>"bbbb");rn$ch = curl_init();rncurl_setopt($ch, CURLOPT_URL, "http://localhost/test.php");rncurl_setopt($ch, CURLOPT_POST, true);rncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);rncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);rncurl_setopt($ch, CURLOPT_TIMEOUT, 30);rn$result = curl_exec($ch);rncurl_close($ch);rnecho $result;rn?> rnrntest.php内容:rn
vb.net 通信接收不到数据
那位可以帮我看下。下列代码第一次发送的时候可以<em>接收</em><em>数据</em>。再发就<em>接收</em><em>不到</em>的原因。 谢谢rnrn Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Clickrn If Button10.Text = "监听" Thenrn t = New Thread(AddressOf datareceive)rn t.Start()rn Button10.Text = "停止"rn listen.Enabled = Falsern Elsernrn listen.Enabled = Truern Button10.Text = "监听"rn 'c_socket1.Close()rn c_socket1.Close()rn t.Abort()rn End Ifrn End SubrnrnrnPublic Sub datareceive()rn Dim i As Integerrn 'Tryrnrn c_socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)rn Dim listenIpEndPoint As New IPEndPoint(IPAddress.Parse(myIp.ToString), Int(listen.Value.ToString.Trim))rn c_socket1.Bind(listenIpEndPoint)rn c_socket1.Listen(1028)rn While (True)rn Dim c_socket2 As Socket = c_socket1.Accept() '''''<em>接收</em>到的<em>数据</em>rnrn Dim returnData As String '''''<em>接收</em>到的<em>数据</em>(字符串型)rnrnrn Dim receiveBytes(2048) As Bytern i = c_socket2.Receive(receiveBytes)rn Dim datare(i - 1) As Bytern Array.Copy(receiveBytes, datare, i)rn '''''判断显示类型rnrn Select Case typeSelect.Text.Trimrnrn Case "ASCII值"rnrn returnData = Encoding.ASCII.GetString(datare)rnrn Case "ASCII码"rnrn returnData = byteToString(datare)rnrn Case "UNICODE"rnrn returnData = Encoding.Unicode.GetString(datare)rnrn Case Elsernrn returnData = byteToString(datare)rnrn End Selectrn '''''显示处理rn lbReceive.Items.Insert(0, returnData) '''''将其插入到列表框的第一项之前rn receiveCount.Text = receiveCount.Text + 1rn addSysInfo("<em>接收</em>到一条<em>数据</em>!")rn End Whilernrn 'Catch ex As Exceptionrn ' 'addSysInfo(SocketException.ErrorCode)rnrn 'End Tryrn End Subrnrn '---------------------------------------------------------rn ' 增加一条系统提示<em>信息</em>rn '---------------------------------------------------------rn Sub addSysInfo(ByVal str As String)rnrn Dim h As String = ""rnrn Dim m As String = ""rnrn Dim s As String = ""rnrn If Now.Hour < 10 Thenrnrn h = "0" & Now.Hourrnrn Elsernrn h = Now.Hourrnrn End Ifrnrn If Now.Minute < 10 Thenrnrn m = "0" & Now.Minuternrn Elsernrn m = Now.Minuternrn End Ifrnrn If Now.Second < 10 Thenrnrn s = "0" & Now.Secondrnrn Elsernrn s = Now.Secondrnrn End Ifrnrn str = "[ " & h & ":" & m & ":" & s & " ] " & strrnrn lbInfo.Items.Insert(0, str)rnrn End Sub
udp广播,接收不到数据??????
msdn上有一个udp广播的例子!rn大概这样rn发送广播: Dim addressa As IPAddress = IPAddress.Parse("224.0.0.1")rn Dim udp1 As New UdpClientrn udp1.Send(bytea, bytea.Length, ipport)rn udp1.Close()rn<em>接收</em>广播: Dim GroupAddress As IPAddress = IPAddress.Parse("224.0.0.1")rn Dim bytea() As Byte = udpa.Receive(ipport)rnrn我把代码运行后<em>接收</em><em>不到</em>!!!rn我感觉是广播地址添的有<em>问题</em>!!rn如果我的ip是192.168.100.129到192.168.100.144,子网是255.255.255.240rn我的广播地址应该如何添呢???为什摸??rnrn最后10分
shiro后端接收不到数据
1.出现后台接受<em>不到</em><em>数据</em> 也许是出了302 看了下以下文章    302定义 302 redirect: 302 代表暂时性转移(Temporarily Moved )。 意思就是你访问网址A,但是网址A因为服务器端的拦截器或者其他后端代码处理的原因,会被重定向到网址B。 解决方法 我这里出现302错误的原因是由于我的后端代码写了拦截器Filter,当从网站A访问带有某关键词路径的接口时...
BeginReceiveFrom 接收不到数据 C#
我写了一个简单的发送接受程序 用的是UDP无连接异步传输.一个窗体里就包含了 接受和发送的控件.rnpublic Socket udpS rnpublic Socket udpRrnbyte[] sendByteBufferrnbyte[] recvByteBufferrn是全局变量.rnForm1_Load()里:rnudpR rnudpS都绑定为"本地主机IP:0"rnrecvep 是 "0.0.0.0:0"rnudpS.BeginReceiveFrom(recvByteBuffer, 0, recvByteBuffer.Length, SocketFlags.None, ref recvep, new AsyncCallback(ReceiveCallback), udpS);rnReceiveCallback函数是:rn private void ReceiveCallback(IAsyncResult ar)rn rn MessageBox.Show("Receive message!");rn Socket result = (Socket)ar.AsyncState;rnrn IPEndPoint exp = new IPEndPoint(IPAddress.Any, 0);rn EndPoint recvep = (EndPoint)exp;rn int recv = 0;rn tryrn rn //(1) 0)rn rn textBox2.Text += Encoding.BigEndianUnicode.GetString(recvByteBuffer, 0, recv );rnrn Array.Clear(recvByteBuffer, 0, recvByteBuffer.Length);rnrn result.BeginReceiveFrom(recvByteBuffer, 0, recvByteBuffer.Length, SocketFlags.None, ref recvep, new AsyncCallback(ReceiveCallback), result);rn rn elsern rn MessageBox.Show("end");rn result.Close();rn rn rnrn发送端:rn用过udpS.BeginSendTo 也用过 udpS.SendTo rnrn<em>问题</em>是,我如果全部都用一个Socket对象,比如说全部用udpS 会在(1)的地方出现"远程主机强迫关闭了一个现有的连接"的异常.导致接受<em>不到</em><em>数据</em>.rn如果我用udpS 发送<em>数据</em>udpR 接受 那么连回调函数都进不去,就是说,根本连进ReceiveCallback调试的机会也没有.rn我不知道<em>问题</em>出在哪里,哪位大哥帮忙看看啊,到底是哪里错了,是我的IP绑的有<em>问题</em>,还是哪个地方写错了.
C# 串口接收不到数据
我用串口调试助手可以<em>接收</em>到<em>数据</em>,但是用自己编写加修改人家代码得到的C#串口<em>接收</em><em>不到</em><em>数据</em>,请高手指教,我将代码贴出来rnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Text;rnusing System.Windows.Forms;rn//using System.Threading;rnusing System.Collections;rnusing System.Threading;rnusing System.IO.Ports; //--导入串口通讯所需命名空间,作用待定rnrnnamespace SerialPortrnrn public partial class Serial : Formrn rn public Serial()rn rn InitializeComponent();rn rnrn private void Form1_Load(object sender, EventArgs e)rn rn try //--使用try catch防止串口获取出现错误rn rn string[] szPorts = System.IO.Ports.SerialPort.GetPortNames(); //--获取当前PC机接入串口rn combSerialPort.Items.AddRange(szPorts); //--rn combSerialPort.SelectedIndex = 0;rn rn catch (Win32Exception win32ex) //获取串口出错rn rn MessageBox.Show(win32ex.ToString());rn rn //--串口相关参数初始化rn //--波特率rn serialPort1.PortName = combSerialPort.Text;rn string[] ss = new string[] "9600", "19200", "57600", "115200" ;rn combBaudRate.DataSource = ss;rnrn //--校验位rn combParityBit.DataSource = Enum.GetNames(typeof(Parity));rnrn //--<em>数据</em>位rn ss = new string[] "5", "6", "7", "8" ;rn combDataBit.DataSource = ss;rn combDataBit.Text = "8";rnrn //--停止位rn combStopBits.DataSource = Enum.GetNames(typeof(StopBits));rn combStopBits.Text = Enum.Format(typeof(StopBits), StopBits.One, "G");rn serialPort1.Encoding = Encoding.GetEncoding("gb2312");//<em>接收</em>发送转换编码rn rnrn private void btnOpenCom_Click(object sender, EventArgs e)rn rn tryrn rn if (serialPort1.IsOpen)rn rn serialPort1.Close();rn rn elsern rn serialPort1.PortName = combSerialPort.Text;rn serialPort1.BaudRate = Convert.ToInt32(combBaudRate.Text);rn serialPort1.Parity = (Parity)Enum.Parse(typeof(Parity), combParityBit.Text);rn serialPort1.DataBits = Int32.Parse(combDataBit.Text);rn serialPort1.StopBits = (StopBits)Enum.Parse(typeof(StopBits), combStopBits.Text);rn serialPort1.Encoding = Encoding.GetEncoding("Gb2312");rn serialPort1.Open();rn rn RefrespictureBox1();rn //--串口<em>信息</em>显示rn toolStripStatusLabel1.Text = "串口:" + combSerialPort.SelectedItem.ToString() rn + " 波特率:" + combBaudRate.SelectedItem.ToString() rn + " <em>数据</em>位:"+combParityBit.SelectedItem.ToString()rn + " 停止位:" + combStopBits.SelectedItem.ToString(); //--综合显示<em>信息</em>rn textBox1.Text =DateTime.Now.ToString();rnrn rn catch (Exception)rn rn rnrn public void RefrespictureBox1()rn rn if (serialPort1.IsOpen)rn rn btnOpenCom.BackColor = SystemColors.GradientActiveCaption;rn btnOpenCom.Text = "关闭";rn rn elsern rn btnOpenCom.BackColor = SystemColors.Control;rn btnOpenCom.Text = "打开";rn rn rnrn private void btnSendData_Click(object sender, EventArgs e)rn rn tryrn rn string s = "";rn if (checkBox1.Checked) //--16进制发送rn rn ArrayList al = MyClass.Str16ToArrayList(editSendData.Text); //--MyClass是自定义的一个类rn //--转化后<em>数据</em>rn byte[] by = new byte[al.Count];rn int i = 0;rn foreach (string stmp in al)rn rn by[i] += Convert.ToByte(stmp, 16);rn i++;rn rn s = Encoding.GetEncoding("Gb2312").GetString(by); rn rn else rn rn s = editSendData.Text;rn rn serialPort1.Write(s); //--串口发送rn rn catch (Exception)rn rn rnrnrnrn //--**************多线程操作!*********************--//rn delegate void SetTextCallback(string text);rn private void SetText(string text)rn rn tryrn rn //--获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用 Invoke 方法,rn //--因为调用方位于创建控件所在的线程以外的线程中,主要判断是否是调用方位于创建控件所在的线程以外的线程中rn if (this.editRecvData.InvokeRequired)rn rn SetTextCallback d = new SetTextCallback(SetText);//--使用委托。rn this.Invoke(d, new object[] text ); //--在拥有此控件的基础窗口句柄的线程上执行指定的委托rn rn elsern rn this.editRecvData.Text += text; //--同一线程时修改属性值rn rn rn catch (Exception)rn rn rn rnrn //--backgroundWorker1_DoWorkrn private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)rn rn char[] c;rn while (true)rn rn tryrn rn if (serialPort1.IsOpen)rn rn c = new char[serialPort1.BytesToRead]; rn serialPort1.Read(c, 0, c.Length); rn if (c.Length > 0)rn rn if (checkBox2.Checked)rn rn byte[] by = Encoding.GetEncoding("Gb2312").GetBytes(c);rn foreach (byte btmp in by)rn rn string s = "00" + string.Format("0:X", btmp);rn s = s.Substring(s.Length - 2, 2);rn SetText(new string(s.ToCharArray()));rn SetText(" ");rn rn rn elsern rn SetText(new string(c));rn rn rn rn rn catch (Exception) rn Thread.Sleep(1);rn rn rnrn private void checkBox1_CheckedChanged(object sender, EventArgs e)rn rn string s = "";rn if (checkBox1.CheckState == CheckState.Checked)rn rn byte[] by = Encoding.GetEncoding("Gb2312").GetBytes(editSendData.Text);rn editSendData.Text = "";rn foreach (byte btmp in by)rn rn s = "00" + string.Format("0:X", btmp);rn editSendData.Text += s.Substring(s.Length - 2, 2);rn editSendData.Text += " ";rn rn rn elsern rn ArrayList al = MyClass.Str16ToArrayList(editSendData.Text);rn byte[] by = new byte[al.Count];rn int i = 0;rn foreach (string stmp in al)rn rn by[i] += Convert.ToByte(stmp, 16);rn i++;rn rn editSendData.Text = Encoding.GetEncoding("Gb2312").GetString(by);rn rn rn rn //--默认关闭界面保存<em>数据</em>rn private void Form1_FormClosed(object sender, FormClosedEventArgs e)rn rn Properties.Settings.Default.Save();rn rnrn private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)rn rn editRecvData.Text = "";rn rn //--------**********************-------//rn private void editSendData_KeyPress(object sender, KeyPressEventArgs e)rn rn if (checkBox1.CheckState == CheckState.Checked)rn rn if (!Uri.IsHexDigit(e.KeyChar) && e.KeyChar != ' ')rn rn e.KeyChar = (char)0;rn rn rn rnrn rnrn
vb mscomm 接收不到数据
[code=vb][/code]rnPrivate Sub Form_Load()rn Dim i As Integerrn If MSComm1.PortOpen = True Thenrn MSComm1.PortOpen = Falsern End If '先判断串口是否关闭,如果打开则关闭rn MSComm1.CommPort = 5 'COM端口rn MSComm1.Settings = "115200,n,8,1"rn MSComm1.InputLen = 0 '读取<em>接收</em>缓冲区的所有字符rn MSComm1.InputMode = comInputModeBinary '采用二进制传输rn MSComm1.InBufferSize = 1024 '接受缓冲区为1024字节rn MSComm1.OutBufferSize = 2048 '发送缓冲区位2048字节rn MSComm1.InBufferCount = 0 '清空接受缓冲区rn MSComm1.OutBufferCount = 0 '清空传输缓冲区rn MSComm1.SThreshold = 0 '禁止发送事件rn MSComm1.RThreshold = 1 '产生MSComm事件rn Command2.Enabled = False '初始化时设置“关闭”按钮不可用 rnEnd SubrnrnPrivate Sub MSComm1_OnComm()rnrn Dim inbyte() As Byte '存储<em>接收</em>串口<em>数据</em>rn Dim buffer As String '存储处理后的串口<em>数据</em>rn Dim lenbuffer As Integer '存储处理后的串口<em>数据</em>长度rn Dim i As Integer '设置循环变量rn rn Select Case MSComm1.CommEventrn Case comEvReceivern inbyte = MSComm1.Input rn For i = LBound(inbyte) To UBound(inbyte)rn rn If Len(Hex(inbyte(i))) = 1 Thenrn buffer = buffer + "0" + Hex(inbyte(i)) + Chr(32)rn Elsern buffer = buffer + Hex(inbyte(i)) + Chr(32)rn End If rnrn lenbuffer = Len(Replace(Trim(buffer), " ", ""))rnrn Select Case lenbufferrn Case Is = 14rn If CByte("&H" & (Mid(Replace(buffer, " ", ""), 1, 2))) = &HAA _rn And "&H" & (Mid(Replace(buffer, " ", ""), 14 - 4 + 1, 2)) = &H42 _rn And "&H" & (Mid(Replace(buffer, " ", ""), 14 - 2 + 1, 2)) = &H42 Then rn If "&H" & (Mid(Replace(buffer, " ", ""), 14 - 12 + 1, 2)) = &H55 Then rn rn If "&H" & (Mid(Replace(buffer, " ", ""), 14 - 10 + 1, 2)) = &H43 _rn And "&H" & (Mid(Replace(buffer, " ", ""), 14 - 8 + 1, 2)) = &H47 _rn And "&H" & (Mid(Replace(buffer, " ", ""), 14 - 6 + 1, 2)) = &H8A Thenrn Text2.Text = "测试通过"rn End If rn rn End Ifrn End Ifrnrn case is = 18rn ....... 省略rnrn End Selectrn Next irn End Subrnrnrn想问下,为什么上位机<em>接收</em><em>不到</em><em>数据</em>???
TIdUDPServer 的 onread接收不到数据
COM+的中TIdUDPServer 的 onread<em>接收</em><em>不到</em><em>数据</em>,郁闷
linux下,服务器程序接收不到数据
服务器程序很简单,就是一个udp的<em>接收</em>程序,我在虚拟机上试过,可以<em>接收</em><em>数据</em>,但放在外网的服务器上<em>接收</em><em>不到</em>,本地电脑可以ping到外网服务器,我是用普通用户运行服务器程序的,是不是跟用户权限有关啊?
接收不到CAN发送的数据
我使用RL78/F13 R5F10BLGKFB 进行CAN<em>数据</em>传输,CAN相关的代码是通过RS-CAN configurator生成的,将这些文件导入CS+工程中,并进行设置后,开始进行CAN <em>数据</em>发送,但是发送不出去。rnrn通过调试,我发现<em>数据</em>写入到了相应的CAN <em>数据</em>传输寄存器,但是进行发送请求后,相应的发送请求位一直为1[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/19.gif][/img],示波器也测不出波形,实在是找不出哪里出<em>问题</em>了。望各位大侠、大佬指点迷津、不吝赐教,不胜感激!!![img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/2.gif][/img]
recvfrom接收不到数据,求解
用SmartSniff抓包看到<em>接收</em>缓冲区里有<em>数据</em>,可是用recvfrom<em>接收</em><em>数据</em>时,有时可以<em>接收</em>到<em>数据</em>,有时却收<em>不到</em><em>数据</em>,求解释。
为什么MSComm接收不到数据
MScom->InputMode = comInputModeBinary;rnMScom->RTreshold = 1;rn一点反应都没有rn还有一点就是怎样把字符串转化成二进制发送出去,谢谢!
win2003超级终端接收不到数据
win2003系统,用超级终端电话线拨号连接一台XP习题计算机,win2003可以发送<em>数据</em>文件,但<em>接收</em><em>不到</em><em>数据</em>
数据接收问题:串口数据接收不完整,什么原因呢?
通过工具连续发送<em>数据</em>一段时间后,停止500ms,然后再发一串<em>数据</em>。rn停止500ms之后,再发送的<em>数据</em>系统就收<em>不到</em>了啊。rnrn反复测试,这个<em>问题</em>一直存在。rnrn请高手指点。rnrnc# serialportrnusb转串口。
CSocket数据接收时的问题
在OnReceive里进行处理rnlen = m_sock->Receive(rBuf, 2048);rnProcessData(rBuf, len);rn我想问的是如果一次ProcessData尚未处理完 又有<em>数据</em>发过来 这时会不会有<em>数据</em>丢失
关于阻塞接收问题
服务器同时启动多个线程来管理客户端,每个客户分配一个线程,当客户端连接到服务器后,服务器马上以<em>阻塞</em>模式<em>接收</em><em>数据</em>,经常会发生工作线程被<em>阻塞</em>的情况,如果在<em>接收</em><em>数据</em>前Sleep一下这样发生<em>阻塞</em>的情况会少的多,但是还是会存在。请问这是为什么?
阻塞方式下数据传输接收问题
我用线程<em>阻塞</em>方式传输<em>数据</em>,客户端代码如:rn  WskStream->Write(m_sUserName.c_str(),m_sUserName.Length());rn WskStream->Write(m_sProjCode.c_str(),m_sProjCode.Length()); rn  WskStream->Write(m_sProjName.c_str(),m_sProjName.Length());rn if(!WskStream->WaitForData(TimeOut))rn rn Msg("连接服务器超时.");rn delete WskStream;rn ClientSocket1->Active=false;rn ::Sleep(500);rn return;rn rn iRtn=WskStream->Read(FlagBuf,FLAG_BUF_SIZE);rn memcpy(Flag,FlagBuf,iRtn);rn if(strcmpi(Flag,sBack)!=0)rn rn Msg("服务器响应错误.");rn delete WskStream;rn ClientSocket1->Active=false;rn ::Sleep(500);rn return;rn rn服务端代码如:rn    if(WskStream->WaitForData(TimeOut))rn rn iRtn=WskStream->Read(FlagBuf,FLAG_BUF_SIZE);rn memcpy(sUserName,FlagBuf,iRtn);rn rn if(WskStream->WaitForData(TimeOut))rn rn iRtn=WskStream->Read(FlagBuf,FLAG_BUF_SIZE);rn memcpy(sProjCode,FlagBuf,iRtn);//在此发觉<em>接收</em>了客户端第二第三步发送的<em>数据</em>rn rn if(WskStream->WaitForData(TimeOut))rn rn iRtn=WskStream->Read(FlagBuf,FLAG_BUF_SIZE);rn memcpy(sProjName,FlagBuf,iRtn);//到这里后可能就<em>接收</em><em>不到</em>客户端第三步发送的<em>数据</em>了,就塞在这里,而客户端需要下面的OK回应,可得<em>不到</em>,客户端就超时了,这种情况为什么会发生?应该怎样解决呀。rn rn rn WskStream->Write("OK\0",3);
为何我的DataGrid在RenderControl之后,STRINGWRITER接收不到任何信息
DataGrid3绝对有<em>数据</em>,但是strOutput就<em>接收</em><em>不到</em>任何<em>信息</em>。rnrnPrivate Function cbfExportExcel(ByVal dt As Data.DataTable) As Stringrn Dim strOutput As Stringrn Response.ClearHeaders()rn Response.ContentType = "text/plaincharset=gb2312"rn Response.AddHeader("content-disposition", String.Format("attachment filename= 0", HttpUtility.UrlEncode("Excel.csv")))rn DataGrid3.DataSource = dt.DefaultViewrn DataGrid3.DataBind()rnrn Me.EnableViewState = Falsern Dim tw As New System.IO.StringWriter()rn Dim hw As New System.Web.UI.HtmlTextWriter(tw)rnrn Me.DataGrid3.RenderControl(hw)rn strOutput = tw.ToString()‘’<em>接收</em><em>不到</em>任何<em>信息</em>rn Response.Write(tw) '('strOutput)rn Response.End()rn Return ""rnrnend functionrn
为何我的DataGrid.RenderControl之后,STRINGWRITER接收不到任何信息
DataGrid3绝对有<em>数据</em>,但是strOutput就<em>接收</em><em>不到</em>任何<em>信息</em>。rnrnPrivate Function cbfExportExcel(ByVal dt As Data.DataTable) As Stringrn Dim strOutput As Stringrn Response.ClearHeaders()rn Response.ContentType = "text/plaincharset=gb2312"rn Response.AddHeader("content-disposition", String.Format("attachment filename= 0", HttpUtility.UrlEncode("Excel.csv")))rn DataGrid3.DataSource = dt.DefaultViewrn DataGrid3.DataBind()rnrn Me.EnableViewState = Falsern Dim tw As New System.IO.StringWriter()rn Dim hw As New System.Web.UI.HtmlTextWriter(tw)rnrn Me.DataGrid3.RenderControl(hw)rn strOutput = tw.ToString()‘’<em>接收</em><em>不到</em>任何<em>信息</em>rn Response.Write(tw) '('strOutput)rn Response.End()rn Return ""rnrnend functionrn
关于阻塞接收
recv()一直<em>阻塞</em>直到有<em>数据</em><em>接收</em>!rn如何设置<em>阻塞</em><em>接收</em>的时间?rn是用setsockopt()吗?rn我现在要设置成1秒钟,具体使用方法,代码是?rn谢谢了rn
为何我的DataGrid的RenderControl之后,STRINGWRITER接收不到任何信息
DataGrid3绝对有<em>数据</em>,但是strOutput就<em>接收</em><em>不到</em>任何<em>信息</em>。rnrnPrivate Function cbfExportExcel(ByVal dt As Data.DataTable) As Stringrn Dim strOutput As Stringrn Response.ClearHeaders()rn Response.ContentType = "text/plaincharset=gb2312"rn Response.AddHeader("content-disposition", String.Format("attachment filename= 0", HttpUtility.UrlEncode("Excel.csv")))rn DataGrid3.DataSource = dt.DefaultViewrn DataGrid3.DataBind()rnrn Me.EnableViewState = Falsern Dim tw As New System.IO.StringWriter()rn Dim hw As New System.Web.UI.HtmlTextWriter(tw)rnrn Me.DataGrid3.RenderControl(hw)rn strOutput = tw.ToString()‘’<em>接收</em><em>不到</em>任何<em>信息</em>rn Response.Write(tw) '('strOutput)rn Response.End()rn Return ""rnrnend functionrn
请教:为何接收不到多个命令行参数
[code=VB]Sub Main()rnOn Error GoTo errprorn MsgBox UBound(GetCommandLine)rn Exit Subrnerrpro:rn MsgBox Err.DescriptionrnEnd SubrnFunction GetCommandLine(Optional MaxArgs)rn '声明变量。rn Dim C, CmdLine, CmdLnLen, InArg, I, NumArgsrn '检查是否提供了 MaxArgs 参数。rn If IsMissing(MaxArgs) Then MaxArgs = 10rn ' 使数组的大小合适。rn ReDim ArgArray(MaxArgs)rn NumArgs = 0: InArg = Falsern '取得命令行参数。rn CmdLine = Command()rn CmdLnLen = Len(CmdLine)rn '以一次一个字符的方式取出命令行参数。rn For I = 1 To CmdLnLenrn C = Mid(CmdLine, I, 1)rn '检测是否为 space 或 tab。rn If (C <> " " And C <> vbTab) Thenrn '若既不是 space 键,也不是 tab 键,rn '则检测是否为参数内含之字符。rn If Not InArg Thenrn '新的参数。rn '检测参数是否过多。rn If NumArgs = MaxArgs Then Exit Forrn NumArgs = NumArgs + 1rnInArg = Truern End Ifrn '将字符连接到当前参数中。rn ArgArray(NumArgs) = ArgArray(NumArgs) & Crn Elsern '找到 space 或 tab。rn '将 InArg 标志设置成 False。rn InArg = Falsern End Ifrn Next Irn '调整数组大小使其刚好符合参数个数。rn ReDim Preserve ArgArray(NumArgs)rn '将数组返回。rn GetCommandLine = ArgArray()rnEnd Functionrnrn[/code]rn是代码的原因还是系统的原因?
面向对象程序课程设计下载
面向对象程序设计学生管理系统,程序全面 目  录 1. 设计内容 1 2. 概要设计 1 3. 自定义类及接口说明 2 4. 程序源码 2 5. 程序运行与调试 11 6. 总结 11 7. 参考文献 12 相关下载链接:[url=//download.csdn.net/download/yizhongtian130/1963573?utm_source=bbsseo]//download.csdn.net/download/yizhongtian130/1963573?utm_source=bbsseo[/url]
winCE下查看进程列表的演示程序下载
这是一个演示如何查看当前winCE系统运行的进程列表的程序。程序演示了 CreateToolhelp32Snapshot,Process32First, Process32Next,CloseToolhelp32Snapshot函数的用法。 主要供初学者参考。 相关下载链接:[url=//download.csdn.net/download/pj220/2119950?utm_source=bbsseo]//download.csdn.net/download/pj220/2119950?utm_source=bbsseo[/url]
m18麦网模板 ShopEx4.85下载
m18麦网模板 (for ShopEx4.85) 相关下载链接:[url=//download.csdn.net/download/udhas/3493683?utm_source=bbsseo]//download.csdn.net/download/udhas/3493683?utm_source=bbsseo[/url]
我们是很有底线的