新手问listen函数的NotImplementedError该怎么解决

图片说明

1个回答

看你的app的listen函数的定义,没有实现,主动丢出了 NotImplemented异常。
编写相应的代码实现它,或者不要调用它或者去掉其中throw NotImplementedException

weixin_46067150
weixin_46067150 回复weixin_46067150: 我把别人的tornado例子的原码敲进去也还是这样
3 个月之前 回复
weixin_46067150
weixin_46067150 大佬,这是书本的一个完整的实例呢,是不是其他地方有问题呢
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

C语言网络编程之listen函数的实现

请教: listen函数方法实现,函数体是什么 我抄了一段代码为什么执行到listen函数这儿就不往下执行了也不报错

刚学linux网络编程,有个问题,listen( )函数可以用来监听其他电脑的端口吗?

如果可以是不是可以用这样的流程,先socket()创建描述符, 然后再bind()绑定一个IP地址跟端口?

tornado使用遇到的问题pycharm报错为NotImplementedError Python

简单到不能在简单的代码,但是这个错误真的看不懂,别人好像都没遇到这个问题啊,真萌新求助大佬 ![图片说明](https://img-ask.csdn.net/upload/202002/16/1581857987_236379.png)![图片说明](https://img-ask.csdn.net/upload/202002/16/1581858004_793028.png)

Golang net.ListenTCP结构

<div class="post-text" itemprop="text"> <p>The definition for the Golang function net.ListenTCP is:</p> <pre><code>func ListenTCP(net string, laddr *TCPAddr) </code></pre> <p>So it takes a string which is the type / version of TCP being used, and then a TCPAddr struct, which defines things like IP address to bind to, port to use etc.</p> <p>However, I often see this function used like this:</p> <pre><code>net.ListenTCP("tcp", ":8080") </code></pre> <p>If the second parameter is looking for a TCPAddr struct / object, why does passing it a string work?</p> </div>

net.Listen和http.ListenAndServe的功能之间的区别

<div class="post-text" itemprop="text"> <p>I'm new to Go and Networking. I know both net.Listen and http.ListenAndServe creates a server. But what is the difference between their functionality?</p> </div>

我在config apache中将“Listen 80”行更改为“Listen 8080”,但仍然无法正常工作

<div class="post-text" itemprop="text"> <p>my apache is ok but when i update my php,Apache will not start and xampp say "Port 80 in use by "Unable to open process" with PID 4!" and i change the "Listen 80" line to "Listen 8080" in config apache but apache say yet "Port 80 in use by "Unable to open process" with PID 4!"</p> </div>

为什么grpc服务器示例使用net.Listen而不是tls.Listen [关闭]

<div class="post-text" itemprop="text"> <p>I'm setting up a golang grpc server that will use TLS for client authorization/authentication. All the examples of server setup that I've seen use <code>net.Listen()</code> instead of <code>tls.Listen()</code>. Why is this?</p> <pre><code>import ( "crypto/tls" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "net" ) func startGRPCListener(hostport string, tlsconfig *tls.Config) (grpcServer *grpc.Server) { listener, _ = net.Listen("tcp", hostport) cred := grpc.Creds(credentials.NewTLS(tlsconfig)) grpcServer := grpc.NewServer(cred) go func() { serveErr := grpcServer.Serve(listener) log.WithError(serveErr).Info("GRPC server exited") }() return } </code></pre> <p>I've noticed in a couple of working examples if I swap to tls.Listen, the connection can no longer be made. However, in other cases, this doesn't cause a problem!</p> <p>I guess my question is "should I use net.Listen or tls.Listen, or does it not make a difference?"</p> </div>

在测试函数中运行ListenAndServe()时,端口没有关闭,该如何解决?

<div class="post-text" itemprop="text"> <p>When I call http.ListenAndServe() in a test function the port does NOT close even after the tests have finished and the process has terminated. So the next time I run the tests I get the error "ListenAndServe: listen tcp :8080: bind: address already in use".</p> <p>This does not happen when I run my program normally through main(). </p> <pre><code>func TestIndex(t *testing.T) { handle := handlers.ServeAndHandle("8080") req, _ := http.NewRequest("GET", "", nil) w := httptest.NewRecorder() handle.ServeHTTP(w, req) if w.Code != http.StatusOK { t.Errorf("Home page didn't return %v", http.StatusOK) } } // this is just a wrapper function of ListenAndServe. m is of type handler func ServeAndHandle(port string) http.Handler { m := &amp;mux{} err := http.ListenAndServe(":"+port, m) // set listen port if err != nil { log.Fatal("ListenAndServe: ", err) } return m } </code></pre> </div>

信号函数需要定义么?

头函数 #ifndef SERVER_H #define SERVER_H #include <QTcpServer> #include <QObject> #include "tcpclientsocket.h" class Server:public QTcpServer { public: Server(QObject *parent=0,int port =0); QList<TcpClientSocket*> tcpClientSocketList; public slots: void updateClients(QString,int); void slotDisconnected(int); protected: void incomingConnection(int socketDescriptor); signals: void updateServer(QString,int); }; #endif SERVER_H 函数 #include "server.h" Server::Server(QObject *parent,int port):QTcpServer(parent) { listen(QHostAddress::Any,port); } void Server::incomingConnection(int socketDescriptor) { TcpClientSocket *tcpClientSocket = new TcpClientSocket(this); connect(tcpClientSocket,SIGNAL(updateClients(QString,int)),this,SLOT(updateClients(QString,int))); connect(tcpClientSocket,SIGNAL(disconnected(int)),this,SLOT(slotDisconnected(int))); tcpClientSocket->setSocketDescriptor(socketDescriptor); tcpClientSocketList.append(tcpClientSocket); } void Server::updateClients(QString msg, int length) { emit updateServer(msg,length); for(int i=0;i<tcpClientSocketList.count();i++) { QTcpSocket *item = tcpClientSocketList.at(i); if(item->write(msg.toLatin1(),length)!=length) { continue; } } } void Server::slotDisconnected(int descriptor) { for(int i=0;i<tcpClientSocketList.count();i++) { QTcpSocket *item=tcpClientSocketList.at(i); if(item->socketDescriptor()==descriptor) { tcpClientSocketList.removeAt(i); return; } } return; } 其中出了个问题error: LNK2019: 无法解析的外部符号 "public: void __cdecl Server::updateServer(class QString,int)" (?updateServer@Server@@QEAAXVQString@@H@Z),该符号在函数 "public: void __cdecl Server::updateClients(class QString,int)" (?updateClients@Server@@QEAAXVQString@@H@Z) 中被引用 造着书模仿的,不知道为什么错

Golang net.Listen绑定到已使用的端口

<div class="post-text" itemprop="text"> <p>Port 8888 is already bound on my (OS X 10.13.5) system, by a process running inside a docker container:</p> <pre><code>$ netstat -an | grep 8888 tcp6 0 0 ::1.8888 *.* LISTEN tcp4 0 0 *.8888 *.* LISTEN </code></pre> <p>A python program which tries to bind to that port (using as close to the socket options of golang as I can manage), fails in the way I expect:</p> <pre class="lang-python prettyprint-override"><code>import socket import fcntl import os def main(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) flag = fcntl.fcntl(sock.fileno(), fcntl.F_GETFL) fcntl.fcntl(sock.fileno(), fcntl.F_SETFL, flag | os.O_NONBLOCK) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.bind(("0.0.0.0", 8888)) sock.listen(5) main() </code></pre> <p>fails with:</p> <pre><code>$ python test.py Traceback (most recent call last): File "test.py", line 15, in &lt;module&gt; main() File "test.py", line 11, in main sock.bind(("0.0.0.0", 8888)) OSError: [Errno 48] Address already in use </code></pre> <p>But a go program creating a connection via <code>net.Listen</code> does not fail, as I expect it to:</p> <pre><code>package main import ( "fmt" "net" ) func main() { _, err := net.Listen("tcp", "0.0.0.0:8888") if err != nil { fmt.Printf("Connection error: %s ", err) } else { fmt.Println("Listening") } } </code></pre> <p>Succeeds with:</p> <pre><code>$ go run test.go Listening </code></pre> <p>A coworker reports that with the same setup, his Ubuntu system correctly fails the go program.</p> <p>Why does this succeed on a Mac, and how can I get the net.Listen to show an error in binding to port 8888?</p> <p>edit: If I occupy port 8888 with a simple go program like:</p> <pre><code>package main import ( "log" "net/http" ) func main() { log.Fatal(http.ListenAndServe("0.0.0.0:8888", nil)) } </code></pre> <p>Then <code>test.go</code> correctly fails to bind to the port. However the docker process (which is running basically that ^^^) does not cause it to fail.</p> <p>edit 2: If I specify "tcp4", then the program does indeed fail as I expect. If I specify "tcp6", it succeeds but netstat says it binds to <code>*</code> instead of <code>::1</code>:</p> <pre><code>$ netstat -an | grep 8888 tcp6 0 0 *.8888 *.* LISTEN tcp6 0 0 ::1.8888 *.* LISTEN tcp4 0 0 *.8888 *.* LISTEN </code></pre> <p>So, specifying "tcp4" will solve my actual problem, but I really want to understand what the heck is going on with the "tcp46" connection type, and I can't find any documentation. Help!</p> </div>

golang 语言新手 请问这是什么错,怎么解决

ListenAndServe: listen tcp :9090: bind: address already in use exit status 1 /bin/bash: shell_session_update: command not found

为什么c++11 thread多线程造成 socket 中accept函数不阻塞?

求大神帮忙看看为什么这里总是运行错误,总是报10022,无效socket的错误 弄了很长时间就是搞不明白,小白一枚,求解,感激 #include <iostream> #include <WinSock2.h> #include <vector> #include <thread> #include <string> using namespace std; #pragma comment(lib,"ws2_32.lib") const short ServerPort=10080; vector<SOCKET> ClientList; SOCKET StartServer(); int AcceptClient(SOCKET serversock); int RecvClientInfo(SOCKET client); //主函数 int main() { SOCKET serversock = StartServer(); cout << "启动服务器" << endl; if (serversock==INVALID_SOCKET) { cout << "服务器启动失败" << endl; closesocket(serversock); WSACleanup(); return -1; } std::thread t1(AcceptClient, serversock);//创建线程接收客户端连接 string cmd; while (true) { cout << "please input cmd:\n"; cin >> cmd; if (cmd=="exit") { closesocket(serversock); WSACleanup(); break; } } return(0); } SOCKET StartServer() { WSADATA wsaData; int nRet = WSAStartup(MAKEWORD(2, 2), &wsaData); if (nRet != 0) { cout << "loading sock field" << endl; return -1; } SOCKET Server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); sockaddr_in addr_Server = { 0 }; addr_Server.sin_family = AF_INET; addr_Server.sin_port = htons(10080); addr_Server.sin_addr.S_un.S_addr = htonl(INADDR_ANY); bind(Server, (SOCKADDR*)&addr_Server, sizeof(addr_Server)); //绑定 listen(Server, SOMAXCONN);//监听 return Server; } int AcceptClient(SOCKET serversock) { do { SOCKET Client ; SOCKADDR addr_Client = { 0 }; int len = sizeof(addr_Client); Client = accept(serversock, (SOCKADDR*)&addr_Client, &len);//接受clientSock /* 这里accept函数本应该阻塞,但是没有阻塞 */ if (Client == INVALID_SOCKET) { cout << "accept client field"<<GetLastError()<<endl; break; } ClientList.push_back(Client); } while (true); return 0; }

求赐教在使用winsock2.h时listen返回-1,GetLastError返回6怎么解决

代码是这样的: ``` void server::onOpenNetwork(Ref * sender) { int lastError; //创建套接字 WORD myVersionRequest; WSADATA wsaData; myVersionRequest = MAKEWORD(1, 1); int err; err = WSAStartup(myVersionRequest, &wsaData); if (!err){ log("已打开套接字\n"); } else{ log("ERROR:嵌套字未打开!"); return; } lastError = WSAGetLastError(); //进一步绑定套接字 SOCKET serSocket = socket(AF_INET, SOCK_STREAM, 0);//创建了可识别套接字 //需要绑定的参数 SOCKADDR_IN addr; addr.sin_family = AF_INET; addr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);//ip地址 addr.sin_port = htons(21567);//绑定端口 /*int bindErr=*/bind(serSocket, (SOCKADDR*)&addr, sizeof(SOCKADDR));//绑定完成 lastError = WSAGetLastError(); int listenErr=listen(serSocket, 10);//其中第二个参数代表能够接收的最多的连接数 if (listenErr < 0) { log("监听失败"); lastError=WSAGetLastError(); } ////////////////////////////////////////////////////////////////////////// //开始进行监听 ////////////////////////////////////////////////////////////////////////// SOCKADDR_IN clientsocket; int len = sizeof(SOCKADDR); while (1) { SOCKET serConn = accept(serSocket, (SOCKADDR*)&clientsocket, &len);//如果这里不是accept而是conection的话。。就会不断的监听 //创建线程来处理这个链接 ClientThread clientDeal = ClientThread(serConn); } WSACleanup();//释放资源的操作 } ``` 说明一下就是,我这里是在cocos2dx里面写的一段代码。作用就是当按下按钮之后调用这个函数打开网络,作为服务器。前面这段代码在win32控制台是可以得,但是拿到这里就不行了,不知道跟这个是不是有关系,求赐教^_^

listen port是什么意思啊?

在学习中看到不明白,请问下? listen port作用和原理 他有特定的端口吗?还是随便的

关于windows下socket编程的recv函数

Talk is cheap,show me the code. do{ # memset(buf, 0, BUFSIZ); # strLen = recv(reads.fd_array[i], buf, BUFSIZ - 1, 0); if (strLen == 0 || strLen == -1){ FD_CLR(reads.fd_array[i], &reads); closesocket(cpyReads.fd_array[i]); printf("closed client:%d \n", cpyReads.fd_array[i]); } else{ printf("From %d : %s", cpyReads.fd_array[i], buf); //send(reads.fd_array[i], buf, strLen, 0); } # } while (strLen==BUFSIZ-1); 我设置的BUFSIZ 是10 我在调用recv函数来取客户端发过来的数据时,如果收到的数据长度大于我设置的缓冲大小也就是BUFSIZ 比如发过来的是10个字符 , 那么do while 循环会循环两次,如果我发送过来的正好是9个字符 , 为啥只循环了一次呢。我调试看到 strLen 明明等于BUFSIZ-1 的 , 于是在上面的memset处加的断点,才知道确实是循环了两次, 可是执行到 recv函数的时候 整个循环直接跳出来了,不太明白这里,求大神讲解一下,站等。。。

安卓的TelephonyManager.listen方法注册的监听小米手机收不到,如何正常处理?

#####需求是要在电话响铃、接听或打出时,暂停当前的音乐播放; #####然而在不获取通话相关权限的状态下,通过TelephonyManager注册通话状态的监听,已测试在大部分机型上可用,然而小米手机却奇葩的收不到监听,只在注册的时候返回了一次当时的通话状态。 #####所以想要问一下大佬们,有没有人碰到过这样的问题,是如何解决的?或者帮我出出主意,还有什么办法可以做到这样的需求。 ####目前已经尝试过的方法 #####1.注册广播BroadcastReceiver,小米手机收不到,相关代码: <code> receiver = new PhoneReceiver(); filter = new IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL); filter.addAction("android.intent.action.PHONE_STATE"); registerReceiver(receiver, filter); </code> #####2.使用TelephonyManager.listen,小米同样不行: <code> tm?.listen(object : PhoneStateListener() { override fun onCallStateChanged(state: Int, phoneNumber: String?) { Log.d("TestV","onCallStateChanged-->[$state], phoneNumber-->[$phoneNumber]") Toast.makeText(this@testTelephonyManager, "收到回调-->$state", Toast.LENGTH_SHORT).show() } }, PhoneStateListener.LISTEN_CALL_STATE) </code> ####在强调下是不请求更多权限的情况下,目前只有'READ_PHONE_STATE' 求大神支招~

nodeJs 里 server.listen 开启服务器的问题

我笔记本上已经运行了 phpstudy 并占用了80端口; 当我运行如下代码时: ``` var http = require('http'); var server = http.createServer(); server.on('listening', function() { console.log('listening...'); }); server.on('error', function(err) { console.log(err); }); server.listen(80, 'localhost'); ``` 输出: listening... 在error事件里。并没有输出80端口被占用的消息,这是嘛回事? 如下是后续补充: 经过我分析,发现我的phpstudy 的apache 监听的0.0.0.0:80端口, 而nodeJs监听的是127.0.0.1:80端口。。 问题延伸: 而我记得,apache不是应该监听的127.0.0.1:80 ,怎么监听0.0.0.0:80去了?

python socket.listen(5)的问题

各位大神好,萌新在看各类python书籍时总是能看到这句代码,理解起来也很费劲,都说一般应用传5就够用了。百度上也都是说在连接被转接或拒绝时传入连接请求的最大数,超过这个值就拒绝了。仔细揣摩过几遍,还是理解不了。像做云平台的,同时可能有上万客户端同一时刻连接进来,难道只能每次接受5个用户么?其他的拒绝连接是不给连接,需要客户端重新请求?

C++ 中的sendTo和recvFrom函数问题

请看代码,addrClient不赋值recvfrom依然可以收到另一个电脑发送的数据;sendto也能发送数据到另一个电脑,为什么????? ``` WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested=MAKEWORD(2,2); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { return; } if (LOBYTE(wsaData.wVersion)!=2 || HIBYTE(wsaData.wVersion)!=2) { WSACleanup(); return; } SOCKET sockSrv=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); SOCKADDR_IN addrSrv; // addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY); addrSrv.sin_addr.S_un.S_addr=inet_addr("192.168.1.253"); addrSrv.sin_family=AF_INET; addrSrv.sin_port=htons(6000); bind(sockSrv,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR)); SOCKADDR_IN addrClient;//addrClient不赋值依然可以收到和发送数据,为什么????? // memset(&addrClient, 0, sizeof(addrClient)); // addrClient.sin_addr.S_un.S_addr=inet_addr("192.168.1.46"); // addrClient.sin_family=AF_INET; // addrClient.sin_port=htons(8080); int len=sizeof(SOCKADDR); char recvBuf[100]; int count = recvfrom(sockSrv,recvBuf,100,0,(SOCKADDR*)&addrClient,&len); sendto(sockSrv,"nullptr", strlen("nullptr")+1, 0, (SOCKADDR*)&addrClient,len); for(int i = 0; i < count; i++) printf("%d\n",recvBuf[i]); closesocket(sockSrv); WSACleanup(); ```

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c# 按行txt c#怎么扫条形码 c#打包html c# 实现刷新数据 c# 两个自定义控件重叠 c#浮点类型计算 c#.net 中文乱码 c# 时间排序 c# 必备书籍 c#异步网络通信
立即提问