Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: net/third_party/udt/app/appserver.cpp

Issue 6708091: Remove UDT. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/third_party/udt/app/appclient.cpp ('k') | net/third_party/udt/app/cc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/third_party/udt/app/appserver.cpp
===================================================================
--- net/third_party/udt/app/appserver.cpp (revision 78992)
+++ net/third_party/udt/app/appserver.cpp (working copy)
@@ -1,155 +0,0 @@
-#ifndef WIN32
- #include <unistd.h>
- #include <cstdlib>
- #include <cstring>
- #include <netdb.h>
-#else
- #include <winsock2.h>
- #include <ws2tcpip.h>
- #include <wspiapi.h>
-#endif
-#include <iostream>
-#include <udt.h>
-#include "cc.h"
-
-using namespace std;
-
-#ifndef WIN32
-void* recvdata(void*);
-#else
-DWORD WINAPI recvdata(LPVOID);
-#endif
-
-
-int main(int argc, char* argv[])
-{
- if ((1 != argc) && ((2 != argc) || (0 == atoi(argv[1]))))
- {
- cout << "usage: appserver [server_port]" << endl;
- return 0;
- }
-
- // use this function to initialize the UDT library
- UDT::startup();
-
- addrinfo hints;
- addrinfo* res;
-
- memset(&hints, 0, sizeof(struct addrinfo));
-
- hints.ai_flags = AI_PASSIVE;
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- //hints.ai_socktype = SOCK_DGRAM;
-
- string service("9000");
- if (2 == argc)
- service = argv[1];
-
- if (0 != getaddrinfo(NULL, service.c_str(), &hints, &res))
- {
- cout << "illegal port number or port is busy.\n" << endl;
- return 0;
- }
-
- UDTSOCKET serv = UDT::socket(res->ai_family, res->ai_socktype, res->ai_protocol);
-
- // UDT Options
- //UDT::setsockopt(serv, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>));
- //UDT::setsockopt(serv, 0, UDT_MSS, new int(9000), sizeof(int));
- //UDT::setsockopt(serv, 0, UDT_RCVBUF, new int(10000000), sizeof(int));
- //UDT::setsockopt(serv, 0, UDP_RCVBUF, new int(10000000), sizeof(int));
-
- if (UDT::ERROR == UDT::bind(serv, res->ai_addr, res->ai_addrlen))
- {
- cout << "bind: " << UDT::getlasterror().getErrorMessage() << endl;
- return 0;
- }
-
- freeaddrinfo(res);
-
- cout << "server is ready at port: " << service << endl;
-
- if (UDT::ERROR == UDT::listen(serv, 10))
- {
- cout << "listen: " << UDT::getlasterror().getErrorMessage() << endl;
- return 0;
- }
-
- sockaddr_storage clientaddr;
- int addrlen = sizeof(clientaddr);
-
- UDTSOCKET recver;
-
- while (true)
- {
- if (UDT::INVALID_SOCK == (recver = UDT::accept(serv, (sockaddr*)&clientaddr, &addrlen)))
- {
- cout << "accept: " << UDT::getlasterror().getErrorMessage() << endl;
- return 0;
- }
-
- char clienthost[NI_MAXHOST];
- char clientservice[NI_MAXSERV];
- getnameinfo((sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), clientservice, sizeof(clientservice), NI_NUMERICHOST|NI_NUMERICSERV);
- cout << "new connection: " << clienthost << ":" << clientservice << endl;
-
- #ifndef WIN32
- pthread_t rcvthread;
- pthread_create(&rcvthread, NULL, recvdata, new UDTSOCKET(recver));
- pthread_detach(rcvthread);
- #else
- CreateThread(NULL, 0, recvdata, new UDTSOCKET(recver), 0, NULL);
- #endif
- }
-
- UDT::close(serv);
-
- // use this function to release the UDT library
- UDT::cleanup();
-
- return 1;
-}
-
-#ifndef WIN32
-void* recvdata(void* usocket)
-#else
-DWORD WINAPI recvdata(LPVOID usocket)
-#endif
-{
- UDTSOCKET recver = *(UDTSOCKET*)usocket;
- delete (UDTSOCKET*)usocket;
-
- char* data;
- int size = 100000;
- data = new char[size];
-
- while (true)
- {
- int rsize = 0;
- int rs;
- while (rsize < size)
- {
- if (UDT::ERROR == (rs = UDT::recv(recver, data + rsize, size - rsize, 0)))
- {
- cout << "recv:" << UDT::getlasterror().getErrorMessage() << endl;
- break;
- }
-
- rsize += rs;
- }
-
- if (rsize < size)
- break;
- }
-
- delete [] data;
-
- UDT::close(recver);
-
- #ifndef WIN32
- return NULL;
- #else
- return 0;
- #endif
-}
« no previous file with comments | « net/third_party/udt/app/appclient.cpp ('k') | net/third_party/udt/app/cc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698